When you put \b
after !
, you require a word char after !
.
See what word boundary matches:
There are three different positions that qualify as word boundaries:
- Before the first character in the string, if the first character is a word character.
- After the last character in the string, if the last character is a word character.
- Between two characters in the string, where one is a word character and the other is not a word character.
Thus, you need to remove \b
if you do not need to check the context after !
, or replace \b
with \B
that will require a non-word char or end of string.
To find EmployeePerson!
as a whole word, just use
\bEmployeePerson!
or
\bEmployeePerson!\B
or - if you need to make sure there are spaces or start/end of string on both ends:
(?<!\s)EmployeePerson!(?!\s)
or - if you want to make sure there are no words chars on both ends:
(?<!\w)EmployeePerson!(?!\w)