Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
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 meditating upon the Monastery: (3)
As of 2019-07-21 13:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    If you were the first to set foot on the Moon, what would be your epigram?






    Results (8 votes). Check out past polls.

    Notices?