Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re^2: Regex code assertion should be able to fail

by nobull (Friar)
on Sep 06, 2007 at 17:22 UTC ( [id://637481]=note: print w/replies, xml ) Need Help??


in reply to Re: Regex code assertion should be able to fail
in thread Regex code assertion should be able to fail

Unless I'm missing something, the technique you describe is essentially the one I described in my original post as the technique I'd use in 5.8 (and was hoping for something more concise).

/(?(?{ whatever() })|(?!))/

Did I miss something?

Update: halley replied via /msg. His post was describing the same technique but gives more details for the benefit of on-lookers.

To clarify how I see this being used here's the code example from my patch to perlre:

@known_animal{ qw( cat dog fox horse rabbit rat ) } = (); @animals = /\b(\w++)(?{ exists $known_animal{$^N} }?)/g; print "@animals\n";

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (6)
As of 2024-03-28 23:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found