x Hint: Register, if you want to hide ads.
x Did you like it? Well, then please consider making a donation :)

Anchors, or atomic zero-width assertions, cause a match to succeed or fail depending on the current position in the string, but they do not cause the engine to advance through the string or consume characters. The metacharacters listed in the following table are anchors.

PatternDescriptionSampleMatches
^The match must start at the beginning of the string or line.^\d{3}"901" in "901-333-123"
$The match must occur at the end of the string or before \n at the end of the line or string.-\d{3}$"-333" in "-901-333"
\AThe match must occur at the start of the string.\A\d{3}"901" in "901-333-"
\ZThe match must occur at the end of the string or before \n at the end of the string.-\d{3}\Z"-333" in "-901-333"
\GThe match must occur at the point where the previous match ended.\G\(\d\)"(1)", "(3)", "(5)" in "(1)(3)(5)[7](9)"
\bThe match must occur on a boundary between a \w (alphanumeric) and a \W (nonalphanumeric) character.\b\w+\s\w+\b"them theme", "them them" in "them theme them them"
\BThe match must not occur on a \b boundary.\Bend\w*\b"ends", "ender" in "end sends endure lender"