{
    "mode": "perldoc",
    "parameter": "Regexp::Common::number",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/Regexp%3A%3ACommon%3A%3Anumber/json",
    "generated": "2026-06-09T11:58:40Z",
    "synopsis": "use Regexp::Common qw /number/;\nwhile (<>) {\n/^$RE{num}{int}$/                and  print \"Integer\\n\";\n/^$RE{num}{real}$/               and  print \"Real\\n\";\n/^$RE{num}{real}{-base => 16}$/  and  print \"Hexadecimal real\\n\";\n}",
    "sections": {
        "NAME": {
            "content": "Regexp::Common::number -- provide regexes for numbers\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "use Regexp::Common qw /number/;\n\nwhile (<>) {\n/^$RE{num}{int}$/                and  print \"Integer\\n\";\n/^$RE{num}{real}$/               and  print \"Real\\n\";\n/^$RE{num}{real}{-base => 16}$/  and  print \"Hexadecimal real\\n\";\n}\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "Please consult the manual of Regexp::Common for a general description of the works of this\ninterface.\n\nDo not use this module directly, but load it via *Regexp::Common*.\n\n$RE{num}{int}{-base}{-sep}{-group}{-places}{-sign}\nReturns a pattern that matches an integer.\n\nIf \"-base => *B*\" is specified, the integer is in base *B*, with \"2 <= *B* <= 36\". For bases\nlarger than 10, upper case letters are used. The default base is 10.\n\nIf \"-sep => *P*\" is specified, the pattern *P* is required as a grouping marker within the\nnumber. If this option is not given, no grouping marker is used.\n\nIf \"-group => *N*\" is specified, digits between grouping markers must be grouped in sequences of\nexactly *N* digits. The default value of *N* is 3. If \"-group => *N,M*\" is specified, digits\nbetween grouping markers must be grouped in sequences of at least *N* digits, and at most *M*\ndigits. This option is ignored unless the \"-sep\" option is used.\n\nIf \"-places => *N*\" is specified, the integer recognized must be exactly *N* digits wide. If\n\"-places => *N,M*\" is specified, the integer must be at least *N* wide, and at most *M*\ncharacters. There is no default, which means that integers are unlimited in size. This option is\nignored if the \"-sep\" option is used.\n\nIf \"-sign => *P*\" is used, it's a pattern the leading sign has to match. This defaults to\n\"[-+]?\", which means the number is optionally preceded by a minus or a plus. If you want to\nmatch unsigned integers, use $RE{num}{int}{-sign => ''}.\n\nFor example:\n\n$RE{num}{int}                          # match 1234567\n$RE{num}{int}{-sep=>','}               # match 1,234,567\n$RE{num}{int}{-sep=>',?'}              # match 1234567 or 1,234,567\n$RE{num}{int}{-sep=>'.'}{-group=>4}    # match 1.2345.6789\n\nUnder \"-keep\" (see Regexp::Common):\n\n$1  captures the entire number\n\n$2  captures the optional sign of the number\n\n$3  captures the complete set of digits\n\n$RE{num}{real}{-base}{-radix}{-places}{-sep}{-group}{-expon}\nReturns a pattern that matches a floating-point number.\n\nIf \"-base=*N*\" is specified, the number is assumed to be in that base (with A..Z representing\nthe digits for 11..36). By default, the base is 10.\n\nIf \"-radix=*P*\" is specified, the pattern *P* is used as the radix point for the number (i.e.\nthe \"decimal point\" in base 10). The default is \"qr/[.]/\".\n\nIf \"-places=*N*\" is specified, the number is assumed to have exactly *N* places after the radix\npoint. If \"-places=*M,N*\" is specified, the number is assumed to have between *M* and *N* places\nafter the radix point. By default, the number of places is unrestricted.\n\nIf \"-sep=*P*\" specified, the pattern *P* is required as a grouping marker within the pre-radix\nsection of the number. By default, no separator is allowed.\n\nIf \"-group=*N*\" is specified, digits between grouping separators must be grouped in sequences of\nexactly *N* characters. The default value of *N* is 3.\n\nIf \"-expon=*P*\" is specified, the pattern *P* is used as the exponential marker. The default\nvalue of *P* is \"qr/[Ee]/\".\n\nIf \"-sign=*P*\" is specified, the pattern *P* is used to match the leading sign (and the sign of\nthe exponent). This defaults to \"[-+]?\", means means that an optional plus or minus sign can be\nused.\n\nFor example:\n\n$RE{num}{real}                  # matches 123.456 or -0.1234567\n$RE{num}{real}{-places=>2}      # matches 123.45 or -0.12\n$RE{num}{real}{-places=>'0,3'}  # matches 123.456 or 0 or 9.8\n$RE{num}{real}{-sep=>'[,.]?'}   # matches 123,456 or 123.456\n$RE{num}{real}{-base=>3'}       # matches 121.102\n\nUnder \"-keep\":\n\n$1  captures the entire match\n\n$2  captures the optional sign of the number\n\n$3  captures the complete mantissa\n\n$4  captures the whole number portion of the mantissa\n\n$5  captures the radix point\n\n$6  captures the fractional portion of the mantissa\n\n$7  captures the optional exponent marker\n\n$8  captures the entire exponent value\n\n$9  captures the optional sign of the exponent\n\n$10 captures the digits of the exponent\n\n$RE{num}{dec}{-radix}{-places}{-sep}{-group}{-expon}\nA synonym for $RE{num}{real}{-base=>10}{...}\n\n$RE{num}{oct}{-radix}{-places}{-sep}{-group}{-expon}\nA synonym for $RE{num}{real}{-base=>8}{...}\n\n$RE{num}{bin}{-radix}{-places}{-sep}{-group}{-expon}\nA synonym for $RE{num}{real}{-base=>2}{...}\n\n$RE{num}{hex}{-radix}{-places}{-sep}{-group}{-expon}\nA synonym for $RE{num}{real}{-base=>16}{...}\n\n$RE{num}{decimal}{-base}{-radix}{-places}{-sep}{-group}\nThe same as $RE{num}{real}, except that an exponent isn't allowed. Hence, this returns a pattern\nmatching *decimal* numbers.\n\nIf \"-base=*N*\" is specified, the number is assumed to be in that base (with A..Z representing\nthe digits for 11..36). By default, the base is 10.\n\nIf \"-radix=*P*\" is specified, the pattern *P* is used as the radix point for the number (i.e.\nthe \"decimal point\" in base 10). The default is \"qr/[.]/\".\n\nIf \"-places=*N*\" is specified, the number is assumed to have exactly *N* places after the radix\npoint. If \"-places=*M,N*\" is specified, the number is assumed to have between *M* and *N* places\nafter the radix point. By default, the number of places is unrestricted.\n\nIf \"-sep=*P*\" specified, the pattern *P* is required as a grouping marker within the pre-radix\nsection of the number. By default, no separator is allowed.\n\nIf \"-group=*N*\" is specified, digits between grouping separators must be grouped in sequences of\nexactly *N* characters. The default value of *N* is 3.\n\nFor example:\n\n$RE{num}{decimal}                  # matches 123.456 or -0.1234567\n$RE{num}{decimal}{-places=>2}      # matches 123.45 or -0.12\n$RE{num}{decimal}{-places=>'0,3'}  # matches 123.456 or 0 or 9.8\n$RE{num}{decimal}{-sep=>'[,.]?'}   # matches 123,456 or 123.456\n$RE{num}{decimal}{-base=>3'}       # matches 121.102\n\nUnder \"-keep\":\n\n$1  captures the entire match\n\n$2  captures the optional sign of the number\n\n$3  captures the complete mantissa\n\n$4  captures the whole number portion of the mantissa\n\n$5  captures the radix point\n\n$6  captures the fractional portion of the mantissa\n\n$RE{num}{square}\nReturns a pattern that matches a (decimal) square. Because Perl's arithmetic is lossy when using\nintegers over about 53 bits, this pattern only recognizes numbers less than 9000000000000000, if\none uses a Perl that is configured to use 64 bit integers. Otherwise, the limit is 2147483647.\nThese restrictions were introduced in versions 2.116 and 2.117 of Regexp::Common. Regardless\nwhether \"-keep\" was set, the matched number will be returned in $1.\n\n$RE{num}{roman}\nReturns a pattern that matches an integer written in Roman numbers. Case doesn't matter. There\nis no unique way of writing Roman numerals, but we will not match anything. We require the Roman\nnumerals to list the symbols in order (largest first). The symbols for thousand (\"M\"), hundred\n(\"C\"), ten (\"X\"), and one (\"I\") can not be repeated more than four times. The symbols for five\nhundred (\"D\"), fifty (\"L\"), and five (\"V\") may not appear more than once. A sequence of four\nrepeated characters may also be written as a subtraction: by using the repeated character just\nonce, and have it followed by the symbol which is 5 or 10 as large. So, four can be written as\n\"IIII\", or as \"IV\", and nine may be written as \"VIIII\" or \"IX\". This corresponds to most modern\nuses of Roman numerals.\n\nThe largest number which will be matched is 4999, or \"MMMMDCCCCLXXXXVIIII\", or \"MMMMCMXCIX\".\n\nUnder \"-keep\", the number will be captured in $1.\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "Regexp::Common for a general description of how to use this interface.\n",
            "subsections": []
        },
        "AUTHOR": {
            "content": "Damian Conway (damian@conway.org)\n",
            "subsections": []
        },
        "MAINTENANCE": {
            "content": "This package is maintained by Abigail (*regexp-common@abigail.be*).\n",
            "subsections": []
        },
        "BUGS AND IRRITATIONS": {
            "content": "Bound to be plenty.\n\nFor a start, there are many common regexes missing. Send them in to *regexp-common@abigail.be*.\n\nLICENSE and COPYRIGHT\nThis software is Copyright (c) 2001 - 2017, Damian Conway and Abigail.\n\nThis module is free software, and maybe used under any of the following licenses:\n\n1) The Perl Artistic License.     See the file COPYRIGHT.AL.\n2) The Perl Artistic License 2.0. See the file COPYRIGHT.AL2.\n3) The BSD License.               See the file COPYRIGHT.BSD.\n4) The MIT License.               See the file COPYRIGHT.MIT.\n",
            "subsections": []
        }
    },
    "summary": "Regexp::Common::number -- provide regexes for numbers",
    "flags": [],
    "examples": [],
    "see_also": []
}