=head1 OPERATORS
=~ determines to which variable the regex is applied.
- In its absence, C<$_> is used.
+ In its absence, $_ is used.
$var =~ /foo/;
x eXtended legibility - free whitespace and comments
c don't reset pos on fails when using /g
- If C<pattern> is an empty string, the last I<successfully> match
- regex is used. Delimiters other than C</> may be used for both this
+ If 'pattern' is an empty string, the last I<successfully> match
+ regex is used. Delimiters other than '/' may be used for both this
operator and the following ones.
qr/pattern/imsox lets you store a regex in a variable,
- or pass one around. Modifiers as for C<m//> and are stored
+ or pass one around. Modifiers as for m// and are stored
within the regex.
s/pattern/replacement/igmsoxe substitutes matches of
- C<pattern> with C<replacement>. Modifiers as for C<m//>
- with addition of C<e>:
+ 'pattern' with 'replacement'. Modifiers as for m//
+ with one addition:
e Evaluate replacement as an expression
'e' may be specified multiple times. 'replacement' is interpreted
as a double quoted string unless a single-quote (') is the delimiter.
- ?pattern? is like C<m/pattern/> but matches only once. No alternate
+ ?pattern? is like m/pattern/ but matches only once. No alternate
delimiters can be used. Must be reset with 'reset'.
=head1 SYNTAX
- \ Escapes the character(s) immediately following it
- . Matches any single character except a newline (unless /s is used)
- ^ Matches at the beginning of the string (or line, if /m is used)
- $ Matches at the end of the string (or line, if /m is used)
- * Matches the preceding element 0 or more times
- + Matches the preceding element 1 or more times
- ? Matches the preceding element 0 or 1 times
- {...} Specifies a range of occurrences for the element preceding it
- [...] Matches any one of the characters contained within the brackets
- (...) Groups regular expressions
- | Matches either the expression preceding or following it
+ \ Escapes the character(s) immediately following it
+ . Matches any single character except a newline (unless /s is used)
+ ^ Matches at the beginning of the string (or line, if /m is used)
+ $ Matches at the end of the string (or line, if /m is used)
+ * Matches the preceding element 0 or more times
+ + Matches the preceding element 1 or more times
+ ? Matches the preceding element 0 or 1 times
+ {...} Specifies a range of occurrences for the element preceding it
+ [...] Matches any one of the characters contained within the brackets
+ (...) Groups subexpressions for capturing to $1, $2...
+ (?:...) Groups subexpressions without capturing (cluster)
+ | Matches either the expression preceding or following it
\1, \2 ... The text from the Nth group
=head2 ESCAPE SEQUENCES
=head2 EXTENDED CONSTRUCTS
(?#text) A comment
- (?:...) Cluster without capturing
(?imxs-imsx:...) Enable/disable option (as per m//)
(?=...) Zero-width positive lookahead assertion
(?!...) Zero-width negative lookahead assertion
(?>...) Grab what we can, prohibit backtracking
(?{ code }) Embedded code, return value becomes $^R
(??{ code }) Dynamic regex, return value used as regex
- (?(cond)yes|no) cond being int corresponding to capturing parens
+ (?(cond)yes|no) cond being integer corresponding to capturing parens
(?(cond)yes) or a lookaround/eval zero-width assertion
=head1 VARIABLES
Richard Soderberg,
Sean M. Burke,
Tom Christiansen,
+Jim Cromie,
and
Jeffrey Goff
for useful advice.