If I have a sentence and I wish to display a word or all words after a particular word has been matched ahead of it, for example I would like to display the word fox
The \b
token is kind of special. It doesn't actually match a character. What it does is it matches any position that lies at the boundary of a word (where "word" in this case is anything that matches \w
). So the pattern (?<=brown\s)(\w+)
would match "bbbbrown fox", but (?<=\bbrown\s)(\w+)
wouldn't, since the position between "bb" and "brown" is in the middle of a word, not at its boundary.