Literal Matching
LAST UPDATED: DECEMBER 29, 2025
A pattern is a Unicode character sequence, including but extending beyond the alphanumeric ASCII set used everyday. In the absence of metacharacters and pattern constructs, literal portions of a pattern are matched exactly and in order against the input text, with matches permitted at any position.
Matching Outcomes
A match succeeds when the pattern matches a contiguous sequence of input characters in order, regardless of position unless constrained by positional constructs.
Wildcard Character
The . matches any single character, including characters with special meaning, except for \n.
Escaping
The \ character removes the special meaning of the subsequent character so it is treated as a literal character.
SPECIAL REGEX CONSTRUCTS
In some cases, the \ and the following character together form a special regex construct rather than a literal character.
EXAMPLES
Backreferences (
\1) - must be escaped.Shorthand character classes (
\d,\s,\w,\D,\S,\W).Word and non-word boundaries (
\b,\B) - must be escaped.