Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

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

by nobull (Friar)
on Sep 06, 2007 at 17:22 UTC ( #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?

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (5)
As of 2021-04-23 08:17 GMT
Find Nodes?
    Voting Booth?

    No recent polls found