Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: offset of named capture buffer

by Athanasius (Archbishop)
on Nov 06, 2012 at 13:51 UTC ( [id://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

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (2)
As of 2024-03-19 04:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found