Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

Re: Identifying the position of match using regular expressions

by tinita (Parson)
on Sep 15, 2012 at 10:59 UTC ( #993865=note: print w/replies, xml ) Need Help??

in reply to Identifying the position of match using regular expressions

if you are using the /g modifier in your regex, you can use pos($string) to get the position after the match.
generally you can use the @- and @+ arrays to get all match offsets and ends.
my $s = "ABCDFEFFAA"; $s =~ m/AA/; say "$-[0] $+[0]"; __END__ 8 10
see perlvar

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://993865]
[Corion]: Well, no computer will start up without the blood sacrifice being made!
[Corion]: I used to cut me on PC cases, but they've gotten better or I don't let blood that easy anymore ;)
[Corion]: You say the girls may strip with your permission, You draw the line dividing art from sin :-D

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (6)
As of 2017-01-16 19:44 GMT
Find Nodes?
    Voting Booth?
    Do you watch meteor showers?

    Results (151 votes). Check out past polls.