Each character matches itself, unless it is one of the special characters + ? . * ^ $ ( ) [ ] { } | \. The special meaning of these characters can be escaped using a \.
Matches an arbitrary character, but not a newline unless it is a single-line match (see m/ /s).
Groups a series of pattern elements to a single element.
Matches the beginning of the target. In multiline mode (see m//m) also matches after every newline character.
Matches the end of the line. In multiline mode also matches before every newline character.
Denotes a class of characters to match. [^] negates the class.
Matches one of the alternatives.
Comment.
Like (regexp) but does not make back-references.
Zero width positive look-ahead assertion.
Zero width negative look-ahead assertion.
Embedded pattern-match modifier. modifier can be one or more of i, m, s, or x.
Quantified subpatterns match as many times as possible. When followed with a ? they match the minimum number of times. These are the quantifiers:
Matches the preceding pattern element one or more times.
Matches zero or one times.
Matches zero or more times.
Denotes the minimum n and maximum m match count. {n} means exactly n times; {n,} means at least n times.
A escapes any special meaning of the following character if non-alphanumeric, but it turns most alphanumeric characters into something special:
Matches alphanumeric, including _, \W matches non-alphanumeric.
Matches whitespace, \S matches non-whitespace.
Matches numeric, \D matches non-numeric.
Matches the beginning of the string, \Z matches the end.
Matches word boundaries, \B matches non-boundaries.
Matches where the previous m/ /g search left off.
Have their usual meaning.
May be used within character classes, \b denotes a backspace in this context.
Back-references:
Refer to matched subexpressions, grouped with ( ), inside the match.
Can also be used if the pattern matches that many subexpressions.
See also $1...$9, $+, $&, $`, and $' in Special Variables.
With modifier x, whitespace can be used in the patterns for readability purposes.