| 1 | =head1 NAME
|
|---|
| 2 |
|
|---|
| 3 | perlreref - Perl Regular Expressions Reference
|
|---|
| 4 |
|
|---|
| 5 | =head1 DESCRIPTION
|
|---|
| 6 |
|
|---|
| 7 | This is a quick reference to Perl's regular expressions.
|
|---|
| 8 | For full information see L<perlre> and L<perlop>, as well
|
|---|
| 9 | as the L</"SEE ALSO"> section in this document.
|
|---|
| 10 |
|
|---|
| 11 | =head2 OPERATORS
|
|---|
| 12 |
|
|---|
| 13 | =~ determines to which variable the regex is applied.
|
|---|
| 14 | In its absence, $_ is used.
|
|---|
| 15 |
|
|---|
| 16 | $var =~ /foo/;
|
|---|
| 17 |
|
|---|
| 18 | !~ determines to which variable the regex is applied,
|
|---|
| 19 | and negates the result of the match; it returns
|
|---|
| 20 | false if the match succeeds, and true if it fails.
|
|---|
| 21 |
|
|---|
| 22 | $var !~ /foo/;
|
|---|
| 23 |
|
|---|
| 24 | m/pattern/igmsoxc searches a string for a pattern match,
|
|---|
| 25 | applying the given options.
|
|---|
| 26 |
|
|---|
| 27 | i case-Insensitive
|
|---|
| 28 | g Global - all occurrences
|
|---|
| 29 | m Multiline mode - ^ and $ match internal lines
|
|---|
| 30 | s match as a Single line - . matches \n
|
|---|
| 31 | o compile pattern Once
|
|---|
| 32 | x eXtended legibility - free whitespace and comments
|
|---|
| 33 | c don't reset pos on failed matches when using /g
|
|---|
| 34 |
|
|---|
| 35 | If 'pattern' is an empty string, the last I<successfully> matched
|
|---|
| 36 | regex is used. Delimiters other than '/' may be used for both this
|
|---|
| 37 | operator and the following ones.
|
|---|
| 38 |
|
|---|
| 39 | qr/pattern/imsox lets you store a regex in a variable,
|
|---|
| 40 | or pass one around. Modifiers as for m// and are stored
|
|---|
| 41 | within the regex.
|
|---|
| 42 |
|
|---|
| 43 | s/pattern/replacement/igmsoxe substitutes matches of
|
|---|
|
|---|