Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: position of first matching regex

by InfiniteSilence (Curate)
on May 17, 2014 at 01:43 UTC ( [id://1086407]=note: print w/replies, xml ) Need Help??


in reply to position of first matching regex

Just set a variable once and only once with the position the first time it matches.

perl -e '$shoo=q!my name is prince!; while($shoo=~m/i/g){$rx = $+[0] +unless $rx } print $rx;
Makes
9

But like Grandfather said, read perlvar.

Celebrate Intellectual Diversity

Log In?
Username:
Password:

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

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

    No recent polls found