This is a question about the answer asked in the question Check the line to see if all characters are hexadecimal values .
The suggested regular expression is as follows:
\A\b[0-9a-fA-F]+\b\Z
Now \A and \Z seem equivalent to ^ and $ respectively. \Z behaves differently because it allows you to use a new line after it (it may or may not be intended).
I donβt understand why the anchor \b "match at word boundary" is used. Isn't the beginning / end of a line always a word boundary?
Ultimately, the regular expression can be rewritten as ^[0-9a-fA-F]$ with the same behavior (without taking into account the problem of returning \n ). Am I missing something? Is \b for some weird edge?
Test cases:
123ABC -> true 123def -> Returns true 123g -> Returns false
knittl Apr 15 '16 at 6:27 2016-04-15 06:27
source share