{
    "content": [
        {
            "type": "text",
            "text": "# perlreref (man)\n\n## NAME\n\nperlreref - Perl Regular Expressions Reference\n\n## DESCRIPTION\n\nThis is a quick reference to Perl's regular expressions.  For full information see perlre and\nperlop, as well as the \"SEE ALSO\" section in this document.\n\n## Sections\n\n- **NAME**\n- **DESCRIPTION**\n- **AUTHOR**\n- **SEE ALSO**\n- **THANKS**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "perlreref",
        "section": "",
        "mode": "man",
        "summary": "perlreref - Perl Regular Expressions Reference",
        "synopsis": null,
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [],
        "examples": [],
        "see_also": [],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 315,
                "subsections": []
            },
            {
                "name": "AUTHOR",
                "lines": 4,
                "subsections": []
            },
            {
                "name": "SEE ALSO",
                "lines": 29,
                "subsections": []
            },
            {
                "name": "THANKS",
                "lines": 6,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "perlreref - Perl Regular Expressions Reference\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "This is a quick reference to Perl's regular expressions.  For full information see perlre and\nperlop, as well as the \"SEE ALSO\" section in this document.\n\nOPERATORS\n\"=~\" determines to which variable the regex is applied.  In its absence, $ is used.\n\n$var =~ /foo/;\n\n\"!~\" determines to which variable the regex is applied, and negates the result of the match;\nit returns false if the match succeeds, and true if it fails.\n\n$var !~ /foo/;\n\n\"m/pattern/msixpogcdualn\" searches a string for a pattern match, applying the given options.\n\nm  Multiline mode - ^ and $ match internal lines\ns  match as a Single line - . matches \\n\ni  case-Insensitive\nx  eXtended legibility - free whitespace and comments\np  Preserve a copy of the matched string -\n${^PREMATCH}, ${^MATCH}, ${^POSTMATCH} will be defined.\no  compile pattern Once\ng  Global - all occurrences\nc  don't reset pos on failed matches when using /g\na  restrict \\d, \\s, \\w and [:posix:] to match ASCII only\naa (two a's) also /i matches exclude ASCII/non-ASCII\nl  match according to current locale\nu  match according to Unicode rules\nd  match according to native rules unless something indicates\nUnicode\nn  Non-capture mode. Don't let () fill in $1, $2, etc...\n\nIf 'pattern' is an empty string, the last successfully matched regex is used. Delimiters\nother than '/' may be used for both this operator and the following ones. The leading \"m\" can\nbe omitted if the delimiter is '/'.\n\n\"qr/pattern/msixpodualn\" lets you store a regex in a variable, or pass one around. Modifiers\nas for \"m//\", and are stored within the regex.\n\n\"s/pattern/replacement/msixpogcedual\" substitutes matches of 'pattern' with 'replacement'.\nModifiers as for \"m//\", with two additions:\n\ne  Evaluate 'replacement' as an expression\nr  Return substitution and leave the original string untouched.\n\n'e' may be specified multiple times. 'replacement' is interpreted as a double quoted string\nunless a single-quote (\"'\") is the delimiter.\n\n\"m?pattern?\" is like \"m/pattern/\" but matches only once. No alternate delimiters can be used.\nMust be reset with reset().\n\nSYNTAX\n\\       Escapes the character immediately following it\n.       Matches any single character except a newline (unless /s is\nused)\n^       Matches at the beginning of the string (or line, if /m is used)\n$       Matches at the end of the string (or line, if /m is used)\n*       Matches the preceding element 0 or more times\n+       Matches the preceding element 1 or more times\n?       Matches the preceding element 0 or 1 times\n{...}   Specifies a range of occurrences for the element preceding it\n[...]   Matches any one of the characters contained within the brackets\n(...)   Groups subexpressions for capturing to $1, $2...\n(?:...) Groups subexpressions without capturing (cluster)\n|       Matches either the subexpression preceding or following it\n\\g1 or \\g{1}, \\g2 ...    Matches the text from the Nth group\n\\1, \\2, \\3 ...           Matches the text from the Nth group\n\\g-1 or \\g{-1}, \\g-2 ... Matches the text from the Nth previous group\n\\g{name}     Named backreference\n\\k<name>     Named backreference\n\\k'name'     Named backreference\n(?P=name)    Named backreference (python syntax)\n\nESCAPE SEQUENCES\nThese work as in normal strings.\n\n\\a       Alarm (beep)\n\\e       Escape\n\\f       Formfeed\n\\n       Newline\n\\r       Carriage return\n\\t       Tab\n\\037     Char whose ordinal is the 3 octal digits, max \\777\n\\o{2307} Char whose ordinal is the octal number, unrestricted\n\\x7f     Char whose ordinal is the 2 hex digits, max \\xFF\n\\x{263a} Char whose ordinal is the hex number, unrestricted\n\\cx      Control-x\n\\N{name} A named Unicode character or character sequence\n\\N{U+263D} A Unicode character by hex ordinal\n\n\\l  Lowercase next character\n\\u  Titlecase next character\n\\L  Lowercase until \\E\n\\U  Uppercase until \\E\n\\F  Foldcase until \\E\n\\Q  Disable pattern metacharacters until \\E\n\\E  End modification\n\nFor Titlecase, see \"Titlecase\".\n\nThis one works differently from normal strings:\n\n\\b  An assertion, not backspace, except in a character class\n\nCHARACTER CLASSES\n[amy]    Match 'a', 'm' or 'y'\n[f-j]    Dash specifies \"range\"\n[f-j-]   Dash escaped or at start or end means 'dash'\n[^f-j]   Caret indicates \"match any character except these\"\n\nThe following sequences (except \"\\N\") work within or without a character class.  The first\nsix are locale aware, all are Unicode aware. See perllocale and perlunicode for details.\n\n\\d      A digit\n\\D      A nondigit\n\\w      A word character\n\\W      A non-word character\n\\s      A whitespace character\n\\S      A non-whitespace character\n\\h      A horizontal whitespace\n\\H      A non horizontal whitespace\n\\N      A non newline (when not followed by '{NAME}';;\nnot valid in a character class; equivalent to [^\\n]; it's\nlike '.' without /s modifier)\n\\v      A vertical whitespace\n\\V      A non vertical whitespace\n\\R      A generic newline           (?>\\v|\\x0D\\x0A)\n\n\\pP     Match P-named (Unicode) property\n\\p{...} Match Unicode property with name longer than 1 character\n\\PP     Match non-P\n\\P{...} Match lack of Unicode property with name longer than 1 char\n\\X      Match Unicode extended grapheme cluster\n\nPOSIX character classes and their Unicode and Perl equivalents:\n\nASCII-         Full-\nPOSIX    range          range    backslash\n[[:...:]]  \\p{...}        \\p{...}   sequence    Description\n\n-----------------------------------------------------------------------\nalnum   PosixAlnum       XPosixAlnum            'alpha' plus 'digit'\nalpha   PosixAlpha       XPosixAlpha            Alphabetic characters\nascii   ASCII                                   Any ASCII character\nblank   PosixBlank       XPosixBlank   \\h       Horizontal whitespace;\nfull-range also\nwritten as\n\\p{HorizSpace} (GNU\nextension)\ncntrl   PosixCntrl       XPosixCntrl            Control characters\ndigit   PosixDigit       XPosixDigit   \\d       Decimal digits\ngraph   PosixGraph       XPosixGraph            'alnum' plus 'punct'\nlower   PosixLower       XPosixLower            Lowercase characters\nprint   PosixPrint       XPosixPrint            'graph' plus 'space',\nbut not any Controls\npunct   PosixPunct       XPosixPunct            Punctuation and Symbols\nin ASCII-range; just\npunct outside it\nspace   PosixSpace       XPosixSpace   \\s       Whitespace\nupper   PosixUpper       XPosixUpper            Uppercase characters\nword    PosixWord        XPosixWord    \\w       'alnum' + Unicode marks\n+ connectors, like\n'' (Perl extension)\nxdigit  ASCIIHexDigit  XPosixDigit            Hexadecimal digit,\nASCII-range is\n[0-9A-Fa-f]\n\nAlso, various synonyms like \"\\p{Alpha}\" for \"\\p{XPosixAlpha}\"; all listed in \"Properties\naccessible through \\p{} and \\P{}\" in perluniprops\n\nWithin a character class:\n\nPOSIX      traditional   Unicode\n[:digit:]       \\d        \\p{Digit}\n[:^digit:]      \\D        \\P{Digit}\n\nANCHORS\nAll are zero-width assertions.\n\n^  Match string start (or line, if /m is used)\n$  Match string end (or line, if /m is used) or before newline\n\\b{} Match boundary of type specified within the braces\n\\B{} Match wherever \\b{} doesn't match\n\\b Match word boundary (between \\w and \\W)\n\\B Match except at word boundary (between \\w and \\w or \\W and \\W)\n\\A Match string start (regardless of /m)\n\\Z Match string end (before optional newline)\n\\z Match absolute string end\n\\G Match where previous m//g left off\n\\K Keep the stuff left of the \\K, don't include it in $&\n\nQUANTIFIERS\nQuantifiers are greedy by default and match the longest leftmost.\n\nMaximal Minimal Possessive Allowed range\n------- ------- ---------- -------------\n{n,m}   {n,m}?  {n,m}+     Must occur at least n times\nbut no more than m times\n{n,}    {n,}?   {n,}+      Must occur at least n times\n{,n}    {,n}?   {,n}+      Must occur at most n times\n{n}     {n}?    {n}+       Must occur exactly n times\n*       *?      *+         0 or more times (same as {0,})\n+       +?      ++         1 or more times (same as {1,})\n?       ??      ?+         0 or 1 time (same as {0,1})\n\nThe possessive forms (new in Perl 5.10) prevent backtracking: what gets matched by a pattern\nwith a possessive quantifier will not be backtracked into, even if that causes the whole\nmatch to fail.\n\nEXTENDED CONSTRUCTS\n(?#text)          A comment\n(?:...)           Groups subexpressions without capturing (cluster)\n(?pimsx-imsx:...) Enable/disable option (as per m// modifiers)\n(?=...)           Zero-width positive lookahead assertion\n(*pla:...)        Same, starting in 5.32; experimentally in 5.28\n(*positivelookahead:...) Same, same versions as *pla\n(?!...)           Zero-width negative lookahead assertion\n(*nla:...)        Same, starting in 5.32; experimentally in 5.28\n(*negativelookahead:...) Same, same versions as *nla\n(?<=...)          Zero-width positive lookbehind assertion\n(*plb:...)        Same, starting in 5.32; experimentally in 5.28\n(*positivelookbehind:...) Same, same versions as *plb\n(?<!...)          Zero-width negative lookbehind assertion\n(*nlb:...)        Same, starting in 5.32; experimentally in 5.28\n(*negativelookbehind:...) Same, same versions as *plb\n(?>...)           Grab what we can, prohibit backtracking\n(*atomic:...)     Same, starting in 5.32; experimentally in 5.28\n(?|...)           Branch reset\n(?<name>...)      Named capture\n(?'name'...)      Named capture\n(?P<name>...)     Named capture (python syntax)\n(?[...])          Extended bracketed character class\n(?{ code })       Embedded code, return value becomes $^R\n(??{ code })      Dynamic regex, return value used as regex\n(?N)              Recurse into subpattern number N\n(?-N), (?+N)      Recurse into Nth previous/next subpattern\n(?R), (?0)        Recurse at the beginning of the whole pattern\n(?&name)          Recurse into a named subpattern\n(?P>name)         Recurse into a named subpattern (python syntax)\n(?(cond)yes|no)\n(?(cond)yes)      Conditional expression, where \"(cond)\" can be:\n(?=pat)   lookahead; also (*pla:pat)\n(*positivelookahead:pat)\n(?!pat)   negative lookahead; also (*nla:pat)\n(*negativelookahead:pat)\n(?<=pat)  lookbehind; also (*plb:pat)\n(*lookbehind:pat)\n(?<!pat)  negative lookbehind; also (*nlb:pat)\n(*negativelookbehind:pat)\n(N)       subpattern N has matched something\n(<name>)  named subpattern has matched something\n('name')  named subpattern has matched something\n(?{code}) code condition\n(R)       true if recursing\n(RN)      true if recursing into Nth subpattern\n(R&name)  true if recursing into named subpattern\n(DEFINE)  always false, no no-pattern allowed\n\nVARIABLES\n$    Default variable for operators to use\n\n$`    Everything prior to matched string\n$&    Entire matched string\n$'    Everything after to matched string\n\n${^PREMATCH}   Everything prior to matched string\n${^MATCH}      Entire matched string\n${^POSTMATCH}  Everything after to matched string\n\nNote to those still using Perl 5.18 or earlier: The use of \"$`\", $& or \"$'\" will slow down\nall regex use within your program. Consult perlvar for \"@-\" to see equivalent expressions\nthat won't cause slow down.  See also Devel::SawAmpersand. Starting with Perl 5.10, you can\nalso use the equivalent variables \"${^PREMATCH}\", \"${^MATCH}\" and \"${^POSTMATCH}\", but for\nthem to be defined, you have to specify the \"/p\" (preserve) modifier on your regular\nexpression.  In Perl 5.20, the use of \"$`\", $& and \"$'\" makes no speed difference.\n\n$1, $2 ...  hold the Xth captured expr\n$+    Last parenthesized pattern match\n$^N   Holds the most recently closed capture\n$^R   Holds the result of the last (?{...}) expr\n@-    Offsets of starts of groups. $-[0] holds start of whole match\n@+    Offsets of ends of groups. $+[0] holds end of whole match\n%+    Named capture groups\n%-    Named capture groups, as array refs\n\nCaptured groups are numbered according to their opening paren.\n\nFUNCTIONS\nlc          Lowercase a string\nlcfirst     Lowercase first char of a string\nuc          Uppercase a string\nucfirst     Titlecase first char of a string\nfc          Foldcase a string\n\npos         Return or set current match position\nquotemeta   Quote metacharacters\nreset       Reset m?pattern? status\nstudy       Analyze string for optimizing matching\n\nsplit       Use a regex to split a string into parts\n\nThe first five of these are like the escape sequences \"\\L\", \"\\l\", \"\\U\", \"\\u\", and \"\\F\".  For\nTitlecase, see \"Titlecase\"; For Foldcase, see \"Foldcase\".\n\nTERMINOLOGY\nTitlecase\n\nUnicode concept which most often is equal to uppercase, but for certain characters like the\nGerman \"sharp s\" there is a difference.\n\nFoldcase\n\nUnicode form that is useful when comparing strings regardless of case, as certain characters\nhave complex one-to-many case mappings. Primarily a variant of lowercase.\n",
                "subsections": []
            },
            "AUTHOR": {
                "content": "Iain Truskett. Updated by the Perl 5 Porters.\n\nThis document may be distributed under the same terms as Perl itself.\n",
                "subsections": []
            },
            "SEE ALSO": {
                "content": "•   perlretut for a tutorial on regular expressions.\n\n•   perlrequick for a rapid tutorial.\n\n•   perlre for more details.\n\n•   perlvar for details on the variables.\n\n•   perlop for details on the operators.\n\n•   perlfunc for details on the functions.\n\n•   perlfaq6 for FAQs on regular expressions.\n\n•   perlrebackslash for a reference on backslash sequences.\n\n•   perlrecharclass for a reference on character classes.\n\n•   The re module to alter behaviour and aid debugging.\n\n•   \"Debugging Regular Expressions\" in perldebug\n\n•   perluniintro, perlunicode, charnames and perllocale for details on regexes and\ninternationalisation.\n\n•   Mastering Regular Expressions by Jeffrey Friedl\n(<http://oreilly.com/catalog/9780596528126/>) for a thorough grounding and reference on\nthe topic.\n",
                "subsections": []
            },
            "THANKS": {
                "content": "David P.C. Wollmann, Richard Soderberg, Sean M. Burke, Tom Christiansen, Jim Cromie, and\nJeffrey Goff for useful advice.\n\n\n\nperl v5.34.0                                 2025-07-25                                 PERLREREF(1)",
                "subsections": []
            }
        }
    }
}