Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^2: how do you use the index function on this example?

by AnomalousMonk (Chancellor)
on Sep 21, 2015 at 22:12 UTC ( #1142679=note: print w/replies, xml ) Need Help??


in reply to Re: how do you use the index function on this example?
in thread how do you use the index function on this example?

And you don't even need the capturing parentheses:

c:\@Work\Perl>perl -wMstrict -le "my $string = 'IIIIMMMMMMMOOOOOOOOOOMMMMMMMMMMMMMMMIIIIIIMMMMOOOO'; ;; while ($string =~ /M+/g) { my ($start, $end) = ($-[0], $+[0]); print qq{start $start, end $end}; } " start 4, end 11 start 21, end 36 start 42, end 46
Note that  @+ holds the positions of the first character after matched sub-strings!


Give a man a fish:  <%-{-{-{-<

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1142679]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (5)
As of 2018-06-19 01:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?



    Results (111 votes). Check out past polls.

    Notices?