I am trying to match the "word" pec+
in the phrase
I cannot find pec+
I have tried the pattern \bpec\+\b
, but there are no matches.
I am trying to match the "word" pec+
in the phrase
I cannot find pec+
I have tried the pattern \bpec\+\b
, but there are no matches.
A word boundary ( \b ) is defined as a spot between two characters that has a \w on one side of it and and a \W on the other side of it (in either order), counting the imaginary characters off the beginning and end of the string as matching a \W .
@ and + being non word chars, there is no \w char to match.
Because
+
is not a word character, you need to end the expression by matching a non word boundary, using\B
:See live demo, showing match for
but not for any of: