in reply to quick regex help for multiple OR
my $regex = join '|', qw( red green blue ); foreach my $line ( @lines ) { next if $line !~ $regex; }
Update: toolic pointed out that the conditions were different for the different colors. A better version would be:
my $negative_regex = join '|', qw( red blue ); my $positive_regex = join '|', qw( green ); foreach my $line ( @lines ) { next if $line =~ $positive_regex || $line !~ $negative_regex; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: quick regex help for multiple OR
by convenientstore (Pilgrim) on May 13, 2008 at 04:11 UTC | |
by McDarren (Abbot) on May 13, 2008 at 10:43 UTC |