Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: offset of named capture buffer

by AnomalousMonk (Abbot)
on Jan 30, 2013 at 13:11 UTC ( #1016057=note: print w/ replies, xml ) Need Help??


in reply to offset of named capture buffer

Per perlre:

"(?<NAME>pattern)"
    A named capture group. Identical in every respect to normal
    capturing parentheses "()" but for the additional fact ...

Don't know if this helps much, but if you already know the ordinal number of the capture group associated with a named capture, then  @- @+   work exactly as advertised. (But it sounds as if you want to go from the named group to its capture group ordinal.)

>perl -wMstrict -le "my $s = 'xxx fooooo yyy'; ;; $s =~ m{ (x+) .*? (?<FOO>fo+) .*? (y+) }xms; ;; print qq{'$1' '$+{FOO}' '$3'}; print qq{'$1' '$2' '$3'}; print qq{/fo+/ at $-[2] to $+[2]}; " 'xxx' 'fooooo' 'yyy' 'xxx' 'fooooo' 'yyy' /fo+/ at 4 to 10


Comment on Re: offset of named capture buffer
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (5)
As of 2014-09-22 03:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (178 votes), past polls