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

Re: offset of named capture buffer

by Athanasius (Canon)
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?

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (4)
As of 2015-12-02 04:05 GMT
Find Nodes?
    Voting Booth?

    My keyboard shows this many letters:

    Results (34 votes), past polls