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

Re^7: Regexp not capturing in named subrules

by Corion (Pope)
on Sep 16, 2009 at 18:49 UTC ( #795694=note: print w/replies, xml ) Need Help??

in reply to Re^6: Regexp not capturing in named subrules
in thread Regexp not capturing in named subrules

I think the way God Intended patterns to be defined for later use is

qr/(?(DEFINE) (?<name>pattern) )/x

Replies are listed 'Best First'.
Re^8: Regexp not capturing in named subrules
by diotalevi (Canon) on Sep 16, 2009 at 18:56 UTC

    Oh, hey. I didn't find that earlier because it seems to be misfiled under the (?(condition)yes-pattern|no-pattern) section but it goes on to answer my original question

    From perlre:

    /(?<NAME>(?&NAME_PAT)) (?(DEFINE) (?<NAME_PAT>....) )/x

    Note that capture buffers matched inside of recursion are not accessible after the recursion returns, so the extra layer of capturing buffers is necessary. Thus $+{NAME_PAT} would not be defined even though $+{NAME} would be.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://795694]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (9)
As of 2017-09-21 16:06 GMT
Find Nodes?
    Voting Booth?
    During the recent solar eclipse, I:

    Results (249 votes). Check out past polls.