The capturing parentheses in the second format are not properly aligned with the double-quote characters. Also, you should use a non-greedy quantifier. In fact, the whole regex can be greatly simplified:
#! perl use strict; use warnings; my $lineCount; while (my $line = <DATA>) { chomp $line; ++$lineCount; if ($line =~ / ( " .*? " ) /x) { my $zone = $1; print "Config line=> $lineCount; Value=> $line; zone=> $zone\n +"; } } __DATA__ set zone "VLAN" vrouter "trust-vr" set zone id 100 "Internet_Only"
Output:
Config line=> 1; Value=> set zone "VLAN" vrouter "trust-vr"; zone=> "V +LAN" Config line=> 2; Value=> set zone id 100 "Internet_Only"; zone=> "Inte +rnet_Only"
Hope that helps,
Athanasius <°(((>< contra mundum
In reply to Re: Problem with alternating regex?
by Athanasius
in thread Problem with alternating regex?
by dwlepage
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |