Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Why does this simple grouping regex not match?

by Anonymous Monk
on Feb 28, 2011 at 13:58 UTC ( [id://890565]=note: print w/replies, xml ) Need Help??


in reply to Why does this simple grouping regex not match?

use re 'debug';
perl -Mre=debug -e '$_ = q!(b).!; /\((?=a|b|c)\)/ && do { print qq{mat +ch! $&\n}; };' perl -Mre=debug -e '$_ = q!(b).!; /\((?=a|b|c)/ && do { print qq{match +! $&\n}; };'
$ perl -Mre=debug -e '$_ = q!(b).!; /\((?=a|b|c)\)/ && do { print qq{m +atch! $&\n}; };' Compiling REx "\((?=a|b|c)\)" Final program: 1: EXACT <(> (3) 3: IFMATCH[0] (16) 5: TRIE-EXACT[abc] (14) <a> <b> <c> 14: SUCCEED (0) 15: TAIL (16) 16: EXACT <)> (18) 18: END (0) anchored "()" at 0 (checking anchored) minlen 2 Guessing start of match in sv for REx "\((?=a|b|c)\)" against "(b)." Did not find anchored substr "()"... Match rejected by optimizer Freeing REx: "\((?=a|b|c)\)" $ perl -Mre=debug -e '$_ = q!(b).!; /\((?=a|b|c)/ && do { print qq{mat +ch! $&\n}; };' Compiling REx "\((?=a|b|c)" Final program: 1: EXACT <(> (3) 3: IFMATCH[0] (16) 5: TRIE-EXACT[abc] (14) <a> <b> <c> 14: SUCCEED (0) 15: TAIL (16) 16: END (0) anchored "(" at 0 (checking anchored) minlen 1 Guessing start of match in sv for REx "\((?=a|b|c)" against "(b)." Found anchored substr "(" at offset 0... Guessed: match at offset 0 Matching REx "\((?=a|b|c)" against "(b)." 0 <> <(b).> | 1:EXACT <(>(3) 1 <(> <b).> | 3:IFMATCH[0](16) 1 <(> <b).> | 5: TRIE-EXACT[abc](14) 1 <(> <b).> | State: 1 Accepted: 0 Charid: + 2 CP: 62 After State: 3 2 <(b> <).> | State: 3 Accepted: 1 Charid: + 2 CP: 0 After State: 0 got 1 possible matches only one match left: #2 <b> 2 <(b> <).> | 14: SUCCEED(0) subpattern success... 1 <(> <b).> | 16:END(0) Match successful! match! ( Freeing REx: "\((?=a|b|c)"

Replies are listed 'Best First'.
Re^2: Why does this simple grouping regex not match?
by december (Pilgrim) on Mar 01, 2011 at 11:46 UTC

    Interesting... didn't know about that. Noted for future use. Thanks!

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (8)
As of 2024-04-19 15:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found