Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: position of first matching regex

by InfiniteSilence (Curate)
on May 17, 2014 at 01:43 UTC ( #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? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (1)
As of 2022-01-18 03:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:












    Results (52 votes). Check out past polls.

    Notices?