Match Whole Words
Word boundary
\b<word>\b matches a whole word
\b strictly matches the following positions:
Before the first character in subject string
After the last character in subject string
Between a word character and a character that is not a word character in subject string
\b<wordchar>and<nonwordchar>\bonly match at the start of a word<wordchar>\band\b<nonwordchar>only match at the end of a word\b<wordchar>\band\b<nonwordchar>\bmatch nothing
Nonboundary
\B strictly matches the following positions:
- Before the first character in subject string if it's not a word character
- After the last character in subject string if it's not a word character
- Between two word characters
- Between two nonword characters
- Empty string