.\" Automatically generated by Pod::Man v1.37, Pod::Parser v1.32
.\" ========================================================================
.de Sh \" Subsection heading
.de Sp \" Vertical space (when we can't use .PP)
.de Vb \" Begin verbatim text
.de Ve \" End verbatim text
.\" Set up some character translations and predefined strings. \*(-- will
.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
.\" double quote, and \*(R" will give a right double quote. | will give a
.\" real vertical bar. \*(C+ will give a nicer C++. Capital omega is used to
.\" do unbreakable dashes and therefore won't be available. \*(C` and \*(C'
.\" expand to `' in nroff, nothing in troff, for use with C<>.
.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
.\" If the F register is turned on, we'll generate index entries on stderr for
.\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index
.\" entries marked with X<> in POD. Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
. tm Index:\\$1\t\\n%\t"\\$2"
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
.\" Fear. Run. Save yourself. No user-serviceable parts.
. \" fudge factors for nroff and troff
. ds #H ((1u-(\\\\n(.fu%2u))*.13m)
. \" simple accents for nroff and troff
. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
. \" troff and (daisy-wheel) nroff accents
.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
.ds ae a\h'-(\w'a'u*4/10)'e
.ds Ae A\h'-(\w'A'u*4/10)'E
. \" corrections for vroff
.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
. \" for low resolution devices (crt and lpr)
.if \n(.H>23 .if \n(.V>19 \
.\" ========================================================================
.TH PERLREREF 1 "2006-01-07" "perl v5.8.8" "Perl Programmers Reference Guide"
perlreref \- Perl Regular Expressions Reference
This is a quick reference to Perl's regular expressions.
For full information see perlre and perlop, as well
as the \*(L"\s-1SEE\s0 \s-1ALSO\s0\*(R" section in this document.
.IX Subsection "OPERATORS"
\& =~ determines to which variable the regex is applied.
\& In its absence, $_ is used.
\& !~ determines to which variable the regex is applied,
\& and negates the result of the match; it returns
\& false if the match succeeds, and true if it fails.
\& m/pattern/igmsoxc searches a string for a pattern match,
\& applying the given options.
\& g Global - all occurrences
\& m Multiline mode - ^ and $ match internal lines
\& s match as a Single line - . matches \en
\& o compile pattern Once
\& x eXtended legibility - free whitespace and comments
\& c don't reset pos on failed matches when using /g
\& If 'pattern' is an empty string, the last I<successfully> matched
\& 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 m// and are stored
\& s/pattern/replacement/igmsoxe substitutes matches of
\& 'pattern' with 'replacement'. Modifiers as for m//
\& 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 m/pattern/ but matches only once. No alternate
\& delimiters can be used. Must be reset with L<reset|perlfunc/reset>.
\& \e Escapes the character 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 subexpression preceding or following it
\& \e1, \e2 ... The text from the Nth group
.Sh "\s-1ESCAPE\s0 \s-1SEQUENCES\s0"
.IX Subsection "ESCAPE SEQUENCES"
These work as in normal strings.
\& \e037 Any octal ASCII value
\& \ex7f Any hexadecimal ASCII value
\& \ex{263a} A wide hexadecimal value
\& \eN{name} A named character
\& \el Lowercase next character
\& \eu Titlecase next character
\& \eL Lowercase until \eE
\& \eU Uppercase until \eE
\& \eQ Disable pattern metacharacters until \eE
\& \eE End case modification
For Titlecase, see \*(L"Titlecase\*(R".
This one works differently from normal strings:
\& \eb An assertion, not backspace, except in a character class
.Sh "\s-1CHARACTER\s0 \s-1CLASSES\s0"
.IX Subsection "CHARACTER CLASSES"
\& [amy] Match 'a', 'm' or 'y'
\& [f-j] Dash specifies "range"
\& [f-j-] Dash escaped or at start or end means 'dash'
\& [^f-j] Caret indicates "match any character _except_ these"
The following sequences work within or without a character class.
The first six are locale aware, all are Unicode aware. The default
character class equivalent are given. See perllocale and
\& \ew A word character [a-zA-Z0-9_]
\& \eW A non-word character [^a-zA-Z0-9_]
\& \es A whitespace character [ \et\en\er\ef]
\& \eS A non-whitespace character [^ \et\en\er\ef]
\& \eC Match a byte (with Unicode, '.' matches a character)
\& \epP Match P-named (Unicode) property
\& \ep{...} Match Unicode property with long name
\& \eP{...} Match lack of Unicode property with long name
\& \eX Match extended unicode sequence
\&\s-1POSIX\s0 character classes and their Unicode and Perl equivalents:
\& alnum IsAlnum Alphanumeric
\& alpha IsAlpha Alphabetic
\& ascii IsASCII Any ASCII char
\& blank IsSpace [ \et] Horizontal whitespace (GNU extension)
\& cntrl IsCntrl Control characters
\& digit IsDigit \ed Digits
\& graph IsGraph Alphanumeric and punctuation
\& lower IsLower Lowercase chars (locale and Unicode aware)
\& print IsPrint Alphanumeric, punct, and space
\& punct IsPunct Punctuation
\& space IsSpace [\es\eck] Whitespace
\& IsSpacePerl \es Perl's whitespace definition
\& upper IsUpper Uppercase chars (locale and Unicode aware)
\& word IsWord \ew Alphanumeric plus _ (Perl extension)
\& xdigit IsXDigit [0-9A-Fa-f] Hexadecimal digit
Within a character class:
\& POSIX traditional Unicode
\& [:digit:] \ed \ep{IsDigit}
\& [:^digit:] \eD \eP{IsDigit}
All are zero-width assertions.
\& ^ Match string start (or line, if /m is used)
\& $ Match string end (or line, if /m is used) or before newline
\& \eb Match word boundary (between \ew and \eW)
\& \eB Match except at word boundary (between \ew and \ew or \eW and \eW)
\& \eA Match string start (regardless of /m)
\& \eZ Match string end (before optional newline)
\& \ez Match absolute string end
\& \eG Match where previous m//g left off
.IX Subsection "QUANTIFIERS"
Quantifiers are greedy by default \*(-- match the \fBlongest\fR leftmost.
\& Maximal Minimal Allowed range
\& ------- ------- -------------
\& {n,m} {n,m}? Must occur at least n times but no more than m times
\& {n,} {n,}? Must occur at least n times
\& {n} {n}? Must occur exactly n times
\& * *? 0 or more times (same as {0,})
\& + +? 1 or more times (same as {1,})
\& ? ?? 0 or 1 time (same as {0,1})
There is no quantifier {,n} \*(-- that gets understood as a literal string.
.Sh "\s-1EXTENDED\s0 \s-1CONSTRUCTS\s0"
.IX Subsection "EXTENDED CONSTRUCTS"
\& (?imxs-imsx:...) Enable/disable option (as per m// modifiers)
\& (?=...) Zero-width positive lookahead assertion
\& (?!...) Zero-width negative lookahead assertion
\& (?<=...) Zero-width positive lookbehind assertion
\& (?<!...) Zero-width negative lookbehind 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 integer corresponding to capturing parens
\& (?(cond)yes) or a lookaround/eval zero-width assertion
.IX Subsection "VARIABLES"
\& $_ Default variable for operators to use
\& $* Enable multiline matching (deprecated; not in 5.9.0 or later)
\& $& Entire matched string
\& $` Everything prior to matched string
\& $' Everything after to matched string
The use of those last three will slow down \fBall\fR regex use
within your program. Consult perlvar for \f(CW@LAST_MATCH_START\fR
to see equivalent expressions that won't cause slow down.
See also Devel::SawAmpersand.
\& $1, $2 ... hold the Xth captured expr
\& $+ Last parenthesized pattern match
\& $^N Holds the most recently closed capture
\& $^R Holds the result of the last (?{...}) expr
\& @- Offsets of starts of groups. $-[0] holds start of whole match
\& @+ Offsets of ends of groups. $+[0] holds end of whole match
Captured groups are numbered according to their \fIopening\fR paren.
.IX Subsection "FUNCTIONS"
\& lcfirst Lowercase first char of a string
\& ucfirst Titlecase first char of a string
\& pos Return or set current match position
\& quotemeta Quote metacharacters
\& reset Reset ?pattern? status
\& study Analyze string for optimizing matching
\& split Use regex to split a string into parts
The first four of these are like the escape sequences \f(CW\*(C`\eL\*(C'\fR, \f(CW\*(C`\el\*(C'\fR,
\&\f(CW\*(C`\eU\*(C'\fR, and \f(CW\*(C`\eu\*(C'\fR. For Titlecase, see \*(L"Titlecase\*(R".
.IX Subsection "TERMINOLOGY"
.IX Subsection "Titlecase"
Unicode concept which most often is equal to uppercase, but for
certain characters like the German \*(L"sharp s\*(R" there is a difference.
This document may be distributed under the same terms as Perl itself.
perlretut for a tutorial on regular expressions.
perlrequick for a rapid tutorial.
perlvar for details on the variables.
perlop for details on the operators.
perlfunc for details on the functions.
perlfaq6 for FAQs on regular expressions.
The re module to alter behaviour and aid
\&\*(L"Debugging regular expressions\*(R" in perldebug
perluniintro, perlunicode, charnames and locale
for details on regexes and internationalisation.
\&\fIMastering Regular Expressions\fR by Jeffrey Friedl
(\fIhttp://regex.info/\fR) for a thorough grounding and