Anchors

Match positions in text

#anchors #boundaries #start #end

Anchors

Anchors match positions rather than characters.

Position Anchors

^       Start of string/line
$       End of string/line
\b      Word boundary
\B      Non-word boundary

Examples

# Match lines starting with "Error"
^Error.*$

# Match whole words only
\bword\b

# Match email at end of line
\S+@\S+\.\S+$

# Match hashtags
#\w+\b

# Match URLs starting with http
^https?://

Word Boundaries

# Match "cat" as whole word (not in "catalog")
\bcat\b

# Match "test" at start of word
\btest

# Match "ing" at end of word
ing\b

Discover another handy tool from EditPDF.pro