dwlepage has asked for the wisdom of the Perl Monks concerning the following question:
Hi, I was hoping someone could help me figure out why I can't seem to make an alternating match work. I've been stumped on this one for a couple days..
Here is the code. Basically I want to match the first value found between double quotes although there are two different formats for the lines:
set zone "VLAN" vrouter "trust-vr"
set zone id 100 "Internet_Only"
In both cases I want to capture the first value and was hoping to do it in a single regex.
Here is what I have that isn't quite working:
if ($line =~ /^set\szone\s("([^"]*)"|id\s\d+\s"([^"]*)")/) { my $zone = $1; print "Config line=> $lineCount; Value=> $line; zone=> $ +zone\n"; }
Any ideas? It matches properly on: set zone "VLAN" vrouter "trust-vr", but the second line is returning: id 100 "Internet Only" when I only want what's between the quotes?
Thanks!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Problem with alternating regex?
by GrandFather (Saint) on Sep 11, 2012 at 03:12 UTC | |
by dwlepage (Novice) on Sep 11, 2012 at 05:16 UTC | |
|
Re: Problem with alternating regex?
by kcott (Archbishop) on Sep 11, 2012 at 05:19 UTC | |
|
Re: Problem with alternating regex?
by jwkrahn (Abbot) on Sep 11, 2012 at 03:38 UTC | |
|
Re: Problem with alternating regex?
by Athanasius (Archbishop) on Sep 11, 2012 at 02:38 UTC | |
by GrandFather (Saint) on Sep 11, 2012 at 03:06 UTC | |
by Athanasius (Archbishop) on Sep 11, 2012 at 03:19 UTC | |
by GrandFather (Saint) on Sep 11, 2012 at 04:21 UTC | |
|
Re: Problem with alternating regex?
by Anonymous Monk on Sep 11, 2012 at 02:54 UTC |