Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

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


Comment on Re: Identifying the position of match using regular expressions
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (9)
As of 2015-07-03 12:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (53 votes), past polls