MOON
Server: Apache/2.2.34 (Unix) mod_ssl/2.2.34 OpenSSL/0.9.8e-fips-rhel5 mod_bwlimited/1.4 FrontPage/5.0.2.2635
System: Linux server.asjudinet.com 2.6.32-042stab141.3 #1 SMP Fri Nov 15 22:45:34 MSK 2019 i686
User: asjudine (504)
PHP: 5.2.17
Disabled: NONE
Upload Files
File: //usr/local/ssl/local/share/man/man1/perlreref.1
.\" Automatically generated by Pod::Man v1.37, Pod::Parser v1.32
.\"
.\" Standard preamble:
.\" ========================================================================
.de Sh \" Subsection heading
.br
.if t .Sp
.ne 5
.PP
\fB\\$1\fR
.PP
..
.de Sp \" Vertical space (when we can't use .PP)
.if t .sp .5v
.if n .sp
..
.de Vb \" Begin verbatim text
.ft CW
.nf
.ne \\$1
..
.de Ve \" End verbatim text
.ft R
.fi
..
.\" 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<>.
.tr \(*W-|\(bv\*(Tr
.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
.ie n \{\
.    ds -- \(*W-
.    ds PI pi
.    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
.    ds L" ""
.    ds R" ""
.    ds C` ""
.    ds C' ""
'br\}
.el\{\
.    ds -- \|\(em\|
.    ds PI \(*p
.    ds L" ``
.    ds R" ''
'br\}
.\"
.\" 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.
.if \nF \{\
.    de IX
.    tm Index:\\$1\t\\n%\t"\\$2"
..
.    nr % 0
.    rr F
.\}
.\"
.\" For nroff, turn off justification.  Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.hy 0
.if n .na
.\"
.\" 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
.if n \{\
.    ds #H 0
.    ds #V .8m
.    ds #F .3m
.    ds #[ \f1
.    ds #] \fP
.\}
.if t \{\
.    ds #H ((1u-(\\\\n(.fu%2u))*.13m)
.    ds #V .6m
.    ds #F 0
.    ds #[ \&
.    ds #] \&
.\}
.    \" simple accents for nroff and troff
.if n \{\
.    ds ' \&
.    ds ` \&
.    ds ^ \&
.    ds , \&
.    ds ~ ~
.    ds /
.\}
.if t \{\
.    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 \
\{\
.    ds : e
.    ds 8 ss
.    ds o a
.    ds d- d\h'-1'\(ga
.    ds D- D\h'-1'\(hy
.    ds th \o'bp'
.    ds Th \o'LP'
.    ds ae ae
.    ds Ae AE
.\}
.rm #[ #] #H #V #F C
.\" ========================================================================
.\"
.IX Title "PERLREREF 1"
.TH PERLREREF 1 "2006-01-07" "perl v5.8.8" "Perl Programmers Reference Guide"
.SH "NAME"
perlreref \- Perl Regular Expressions Reference
.SH "DESCRIPTION"
.IX Header "DESCRIPTION"
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.
.Sh "\s-1OPERATORS\s0"
.IX Subsection "OPERATORS"
.Vb 2
\&  =~ determines to which variable the regex is applied.
\&     In its absence, $_ is used.
.Ve
.PP
.Vb 1
\&        $var =~ /foo/;
.Ve
.PP
.Vb 3
\&  !~ 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.
.Ve
.PP
.Vb 1
\&       $var !~ /foo/;
.Ve
.PP
.Vb 2
\&  m/pattern/igmsoxc searches a string for a pattern match,
\&     applying the given options.
.Ve
.PP
.Vb 7
\&        i  case-Insensitive
\&        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
.Ve
.PP
.Vb 3
\&     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.
.Ve
.PP
.Vb 3
\&  qr/pattern/imsox lets you store a regex in a variable,
\&     or pass one around. Modifiers as for m// and are stored
\&     within the regex.
.Ve
.PP
.Vb 3
\&  s/pattern/replacement/igmsoxe substitutes matches of
\&     'pattern' with 'replacement'. Modifiers as for m//
\&     with one addition:
.Ve
.PP
.Vb 1
\&        e  Evaluate replacement as an expression
.Ve
.PP
.Vb 2
\&     'e' may be specified multiple times. 'replacement' is interpreted
\&     as a double quoted string unless a single-quote (') is the delimiter.
.Ve
.PP
.Vb 2
\&  ?pattern? is like m/pattern/ but matches only once. No alternate
\&      delimiters can be used. Must be reset with L<reset|perlfunc/reset>.
.Ve
.Sh "\s-1SYNTAX\s0"
.IX Subsection "SYNTAX"
.Vb 13
\&   \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
.Ve
.Sh "\s-1ESCAPE\s0 \s-1SEQUENCES\s0"
.IX Subsection "ESCAPE SEQUENCES"
These work as in normal strings.
.PP
.Vb 11
\&   \ea       Alarm (beep)
\&   \ee       Escape
\&   \ef       Formfeed
\&   \en       Newline
\&   \er       Carriage return
\&   \et       Tab
\&   \e037     Any octal ASCII value
\&   \ex7f     Any hexadecimal ASCII value
\&   \ex{263a} A wide hexadecimal value
\&   \ecx      Control-x
\&   \eN{name} A named character
.Ve
.PP
.Vb 6
\&   \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
.Ve
.PP
For Titlecase, see \*(L"Titlecase\*(R".
.PP
This one works differently from normal strings:
.PP
.Vb 1
\&   \eb  An assertion, not backspace, except in a character class
.Ve
.Sh "\s-1CHARACTER\s0 \s-1CLASSES\s0"
.IX Subsection "CHARACTER CLASSES"
.Vb 4
\&   [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"
.Ve
.PP
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
perlunicode for details.
.PP
.Vb 6
\&   \ed      A digit                     [0-9]
\&   \eD      A nondigit                  [^0-9]
\&   \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]
.Ve
.PP
.Vb 6
\&   \eC      Match a byte (with Unicode, '.' matches a character)
\&   \epP     Match P-named (Unicode) property
\&   \ep{...} Match Unicode property with long name
\&   \ePP     Match non-P
\&   \eP{...} Match lack of Unicode property with long name
\&   \eX      Match extended unicode sequence
.Ve
.PP
\&\s-1POSIX\s0 character classes and their Unicode and Perl equivalents:
.PP
.Vb 15
\&   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
.Ve
.PP
Within a character class:
.PP
.Vb 3
\&    POSIX       traditional   Unicode
\&    [:digit:]       \ed        \ep{IsDigit}
\&    [:^digit:]      \eD        \eP{IsDigit}
.Ve
.Sh "\s-1ANCHORS\s0"
.IX Subsection "ANCHORS"
All are zero-width assertions.
.PP
.Vb 8
\&   ^  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
.Ve
.Sh "\s-1QUANTIFIERS\s0"
.IX Subsection "QUANTIFIERS"
Quantifiers are greedy by default \*(-- match the \fBlongest\fR leftmost.
.PP
.Vb 8
\&   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})
.Ve
.PP
There is no quantifier {,n} \*(-- that gets understood as a literal string.
.Sh "\s-1EXTENDED\s0 \s-1CONSTRUCTS\s0"
.IX Subsection "EXTENDED CONSTRUCTS"
.Vb 11
\&   (?#text)         A comment
\&   (?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
.Ve
.Sh "\s-1VARIABLES\s0"
.IX Subsection "VARIABLES"
.Vb 2
\&   $_    Default variable for operators to use
\&   $*    Enable multiline matching (deprecated; not in 5.9.0 or later)
.Ve
.PP
.Vb 3
\&   $&    Entire matched string
\&   $`    Everything prior to matched string
\&   $'    Everything after to matched string
.Ve
.PP
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.
.PP
.Vb 6
\&   $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
.Ve
.PP
Captured groups are numbered according to their \fIopening\fR paren.
.Sh "\s-1FUNCTIONS\s0"
.IX Subsection "FUNCTIONS"
.Vb 4
\&   lc          Lowercase a string
\&   lcfirst     Lowercase first char of a string
\&   uc          Uppercase a string
\&   ucfirst     Titlecase first char of a string
.Ve
.PP
.Vb 4
\&   pos         Return or set current match position
\&   quotemeta   Quote metacharacters
\&   reset       Reset ?pattern? status
\&   study       Analyze string for optimizing matching
.Ve
.PP
.Vb 1
\&   split       Use regex to split a string into parts
.Ve
.PP
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".
.Sh "\s-1TERMINOLOGY\s0"
.IX Subsection "TERMINOLOGY"
\fITitlecase\fR
.IX Subsection "Titlecase"
.PP
Unicode concept which most often is equal to uppercase, but for
certain characters like the German \*(L"sharp s\*(R" there is a difference.
.SH "AUTHOR"
.IX Header "AUTHOR"
Iain Truskett.
.PP
This document may be distributed under the same terms as Perl itself.
.SH "SEE ALSO"
.IX Header "SEE ALSO"
.IP "\(bu" 4
perlretut for a tutorial on regular expressions.
.IP "\(bu" 4
perlrequick for a rapid tutorial.
.IP "\(bu" 4
perlre for more details.
.IP "\(bu" 4
perlvar for details on the variables.
.IP "\(bu" 4
perlop for details on the operators.
.IP "\(bu" 4
perlfunc for details on the functions.
.IP "\(bu" 4
perlfaq6 for FAQs on regular expressions.
.IP "\(bu" 4
The re module to alter behaviour and aid
debugging.
.IP "\(bu" 4
\&\*(L"Debugging regular expressions\*(R" in perldebug
.IP "\(bu" 4
perluniintro, perlunicode, charnames and locale
for details on regexes and internationalisation.
.IP "\(bu" 4
\&\fIMastering Regular Expressions\fR by Jeffrey Friedl
(\fIhttp://regex.info/\fR) for a thorough grounding and
reference on the topic.
.SH "THANKS"
.IX Header "THANKS"
David P.C. Wollmann,
Richard Soderberg,
Sean M. Burke,
Tom Christiansen,
Jim Cromie,
and
Jeffrey Goff
for useful advice.