Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re^2: Simple regex should match number

by Anonymous Monk
on Feb 01, 2012 at 08:10 UTC ( [id://951144]=note: print w/replies, xml ) Need Help??


in reply to Re: Simple regex should match number
in thread Simple regex should match number

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}"

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://951144]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (3)
As of 2024-04-24 03:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found