Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re^4: Problem with alternating regex?

by GrandFather (Cardinal)
on Sep 11, 2012 at 04:21 UTC ( #992915=note: print w/ replies, xml ) Need Help??


in reply to Re^3: Problem with alternating regex?
in thread Problem with alternating regex?

The double quote pairing is in fact correct
# /^set\szone\s("([^"]*)"|id\s\d+\s"([^"]*)")/ # ^ ^ ^ ^

Yes, it is actually the first format which has the right parenthesis in the wrong place. But, as you say, that wasn’t the OP’s problem either.

No. The OP's parenthesis matching really is correct - all of it. The parenthesis pairing is:

# v v # /^set\szone\s("([^"]*)"|id\s\d+\s"([^"]*)")/ # ^ ^ ^ ^

The OP's issue is that the parenthesis marked with 'v' are the $1 capture group. The two sets of parenthesis marked with ^ are what the OP hoped were $1, but really they are redundant grouping parenthesis.

True laziness is hard work


Comment on Re^4: Problem with alternating regex?
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (8)
As of 2014-10-21 03:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (95 votes), past polls