regex - Regular expression and repeating character classes in perl -
i trying write regular expression can extract (possibly multiple) strings of 4 hexadecimal numbers/letters.
i this: /^[a-fa-f0-9][a-fa-f0-9][a-fa-f0-9][a-fa-f0-9]/
but there better way?
it seems repeat operator:
a{n} matches 'a' repeated n times.
a{n,} matches 'a' repeated n or more times.
a{n, m} matches 'a' repeated between n , m times inclusive.
would work, following regular expression not seem work:
/^[a-fa-f0-9]{4}+/
i'm trying match strings like:
aa00
aa00ffaa
0011ffaa0022
and on. each string on it's own line.
thanks!
try this:
/^(?:[a-fa-f0-9]{4})+$/
Comments
Post a Comment