Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^3: RegEx Headaches

by kcott (Canon)
on Jun 22, 2013 at 22:30 UTC ( #1040298=note: print w/replies, xml ) Need Help??


in reply to Re^2: RegEx Headaches
in thread RegEx Headaches

++ Yes, that works and is less complicated still. :-)

It wouldn't have occurred to me not to use a capture group. I checked the online docs and found in perlretut - Using regular expressions in Perl - Global matching (after following links from perlre):

In list context, //g returns a list of matched groupings, or if there are no groupings, a list of matches to the whole regexp. [my emphasis]

That seemed new to me (those links are for 5.16.2), so I checked back to the earliest online perldoc version (5.8.8) and, while in a different manpage (http://perldoc.perl.org/5.8.8/perlop.html#Regexp-Quote-Like-Operators) with different wording, that behaviour was current back then:

In list context, it returns a list of the substrings matched by any capturing parentheses in the regular expression. If there are no parentheses, it returns a list of all the matched strings, as if there were parentheses around the whole pattern. [my emphasis, again]

I've learned something new. Thankyou.

-- Ken

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1040298]
help
Chatterbox?
[choroba]: Půlnoční Marie (which means Midnight Mary)
[choroba]: but the band is practically dead. We rehearse once in a year, and perform with the same frequency
[ambrus]: `quote
[ambrus]: sorry, typed in the wrong box
[LanX]: Your mother: je ne t'aime plus! ;)
[choroba]: seems lispy
[Your Mother]: Be nice! I speak that much French. Though I also like that song.
[choroba]: So, I joined Pod Černý Vrch some months ago to still have the fun. But I wouldn't call it "punk" anymore...
[LanX]: choroba deaf after one rehearsal per year ?
Discipulus .. per ear!

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (10)
As of 2017-03-24 12:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should Pluto Get Its Planethood Back?



    Results (301 votes). Check out past polls.