Beefy Boxes and Bandwidth Generously Provided by pair Networks vroom
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: offset of named capture buffer

by Athanasius (Prior)
on Nov 06, 2012 at 13:51 UTC ( #1002475=note: print w/ replies, xml ) Need Help??


in reply to offset of named capture buffer

See also the 2008 thread Finding match offsets of named captures in 5.10 regex, in which it is suggested that a code block can be used to capture the offset with a call to pos.

Update: An example:

2:56 >perl -Mstrict -wE "my $s = q[My 25 cents.]; my ($p, $q); $s =~ +/(?<myref>(?{$p = pos})\d+(?{$q = pos}))/; say $+{myref}; say $p, q[ +--> ], $q;" 25 3 --> 5 2:56 >

Athanasius <°(((><contra mundum


Comment on Re: offset of named capture buffer
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (10)
As of 2014-04-16 20:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (434 votes), past polls