Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://993865]
help
Chatterbox?
[Discipulus]: thanks choroba.. todo list need a pager..

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (8)
As of 2017-11-24 12:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:













    Results (348 votes). Check out past polls.

    Notices?