Why in this case left \b
performs as left \B
?
\b\$[0-9]+(\.[0-9][0-9])?\b
This pattern should omit phrases such a$99.99
because of performance of left \b
.
\b
detects phrases which have not been bounded with letters, digits or underscore. But not! I examined it in regex101.
as you see it detects phrases such tyh666.8
but doesn't detect $99
However, right \b
performs completely correctly!
Surprisingly, I changed it to left \B
it worked!
\B
detects phrases which have been bounded with letters, digits or underscore. But here it works as a left \b
!
and I have no idea why?!
As you see it detects phrases which have not been bounded with letters, digits or underscore
Your understanding of \b
is incorrect. It matches positions where there are "word" characters on one side, and "not word" characters on the other. $
is not a word character, so it will only match where $
is immediately preceded by a word character (alphanumerics, plus in some implementations e.g. @
and _
)