The boundary matcher meta
Symbol | Description |
---|---|
^ | The beginning of a line |
$ | The end of a line |
\b | A word boundary |
\B | A non-word boundary |
\A | The beginning of the input |
\G | The end of the previous match |
\Z | The end of the input but for the final terminator, if any |
\z | The end of the input |
< | Matches the start of a word |
> | Matches the end of a word |
word boundary
Case 1:
Case 2:
A non-word boundary is \B.
Example 1:
Example 2:
To require the match to occur only at the end of the previous match, use \G:
Example 1:
Example 2:
The second example finds only one match, because the second occurrence of dog does not start at the end of the previous match.