Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

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
Domain Nodelet?
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 browsing the Monastery: (2)
As of 2023-06-08 22:27 GMT
Find Nodes?
    Voting Booth?
    How often do you go to conferences?

    Results (35 votes). Check out past polls.