8Anchors ^ $ \b
Anchors match positions, not characters: start, end and word boundaries.
Anchors do not consume any characters; they assert a position.
^ | start of the text (or of each line with the m flag) |
$ | end of the text (or of each line with m) |
\b | a word boundary – between a word character and a non-word character |
\B | not a word boundary |
^Error only finds Error at the very beginning. \bcat\b finds the word cat but not the cat in concat or cats. ^\d+$ means: the whole text is digits.
Exercises
Lesson complete – well done!