Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: m//g in list context

by dws (Chancellor)
on Aug 08, 2002 at 21:30 UTC ( #188746=note: print w/replies, xml ) Need Help??


in reply to m//g in list context

When invoked with the g modifier in list context, I thought that the return value is a list of all possible matches.

"All possible" implies matches that overlap with other matches. This isn't how regexs work. With /g, the search for the next match begins immediately after the prior match.

In your example, applying the regex   m/(\w):(\w)/g
to   "a:b:c"
matches once ("a:b"). The next search begins at ":c", which doesn't match.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (4)
As of 2020-03-28 23:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    To "Disagree to disagree" means to:









    Results (168 votes). Check out past polls.

    Notices?