Adding use re 'debug'; for m/-?\p{Nd}/ and  m/-?\p{Nd}{1}/ shows
$ perl5.12.2 junk Compiling REx "-?\p{Nd}" synthetic stclass "ANYOF[\-][+utf8::Nd]". Final program: 1: CURLY {0,1} (5) 3: EXACT <-> (0) 5: ANYOF[{unicode}+utf8::Nd] (17) 17: END (0) stclass ANYOF[\-][+utf8::Nd] minlen 1 Matching REx "-?\p{Nd}" against "1" Matching stclass ANYOF[\-][+utf8::Nd] against "1" (1 chars) Contradicts stclass... [regexec_flags] Match failed Doesn't match Freeing REx: "-?\p{Nd}"
$ perl5.14.1 junk Compiling REx "-?\p{Nd}" synthetic stclass "ANYOF{i}[\-][{non-utf8-latin1-all}{unicode}{outside + bitmap}+utf8::Nd]". Final program: 1: CURLY {0,1} (5) 3: EXACT <-> (0) 5: ANYOF[{unicode}{outside bitmap}+utf8::Nd] (16) 16: END (0) stclass ANYOF{i}[\-][{non-utf8-latin1-all}{unicode}{outside bitmap}+ut +f8::Nd] minlen 1 Matching REx "-?\p{Nd}" against "1" Matching stclass ANYOF{i}[\-][{non-utf8-latin1-all}{unicode}{outside b +itmap}+utf8::Nd] against "1" (1 bytes) 0 <> <1> | 1:CURLY {0,1}(5) EXACT <-> can match 0 times out of 1 +... 0 <> <1> | 5: ANYOF[{unicode}{outside bitmap}0-9 +...+utf8::Nd](16) 1 <1> <> | 16: END(0) Match successful! Matches Freeing REx: "-?\p{Nd}"
$ perl5.12.2 junk Compiling REx "-?\p{Nd}{1}" Final program: 1: CURLY {0,1} (5) 3: EXACT <-> (0) 5: CURLY {1,1} (19) 7: ANYOF[{unicode}+utf8::Nd] (0) 19: END (0) minlen 1 Matching REx "-?\p{Nd}{1}" against "1" 0 <> <1> | 1:CURLY {0,1}(5) EXACT <-> can match 0 times out of 1 +... 0 <> <1> | 5: CURLY {1,1}(19) ANYOF[{unicode}0-9...+utf8::Nd] ca +n match 1 times out of 1... 1 <1> <> | 19: END(0) Match successful! Matches Freeing REx: "-?\p{Nd}{1}"
$ perl5.14.1 junk Compiling REx "-?\p{Nd}{1}" Final program: 1: CURLY {0,1} (5) 3: EXACT <-> (0) 5: CURLY {1,1} (18) 7: ANYOF[{unicode}{outside bitmap}+utf8::Nd] (0) 18: END (0) minlen 1 Matching REx "-?\p{Nd}{1}" against "1" 0 <> <1> | 1:CURLY {0,1}(5) EXACT <-> can match 0 times out of 1 +... 0 <> <1> | 5: CURLY {1,1}(18) ANYOF[{unicode}{outside bitmap}0-9 +...+utf8::Nd] can match 1 times out of 1... 1 <1> <> | 18: END(0) Match successful! Matches Freeing REx: "-?\p{Nd}{1}"


In reply to Re^2: Simple regex should match number by Anonymous Monk
in thread Simple regex should match number by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.