Reputation: 3409
I am learning regular expression and trying to understand what value will be matched if the regex represents in hex value.
For example, if I have ^[\\x00-\\xff]{16}
, does this mean that it will match any values from 0-255 for 16 digits long?
I looked on line, can't seem to find the example.
Thanks
Upvotes: 1
Views: 2213
Reputation: 124297
The hexadecimal value refers to the character code of the string character being matched. For example, 'A'
in ASCII or UTF-8 is 65, or x41
.
^[\x00-\xff]{16}
means to match, anchored at the beginning of the string, exactly 16 characters whose numeric values are between 0 and 255. If your regex engine isn't multi-byte-character-set-aware, that will mean any character, so in that case it's almost identical to ^.{16}
, except that in many regex engines .
won't match a newline unless a specific option is turned on (/s
in Perl and Perl-compatible regex).
Upvotes: 2