Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Problem with alternating regex?

by jwkrahn (Monsignor)
on Sep 11, 2012 at 03:38 UTC ( #992912=note: print w/ replies, xml ) Need Help??


in reply to Problem with alternating regex?

$ perl -le' for my $line ( q/set zone "VLAN" vrouter "trust-vr"/, q/set zone id 10 +0 "Internet_Only"/ ) { if ( $line =~ /^set\szone\s(?:"([^"]*)"|id\s\d+\s"([^"]*)")/ ) { my $zone = $^N; print $zone; } } ' VLAN Internet_Only

Or:

$ perl -le' for my $line ( q/set zone "VLAN" vrouter "trust-vr"/, q/set zone id 10 +0 "Internet_Only"/ ) { if ( $line =~ /^set\szone\s(?:id\s\d+\s|)"([^"]*)"/ ) { my $zone = $1; print $zone; } } ' VLAN Internet_Only


Comment on Re: 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://992912]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (14)
As of 2015-07-06 19:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (81 votes), past polls