in reply to quick regex help for multiple OR
The stated problem is not exactly regexp friendly ;-) (to be solved in a single expression), as has been stated by others.
You are looking for a combination of conditions, a problem which might be solved better per parser or similar stuff.
BTW, you can set conditions during the regexp run and jump on the result afterwards. This might be handy if you have several conditions which depend linearly on the input data, sth. like:
... our $c; my $regex = qr{ red (?{$c|=4}) | green (?{$c|=2}) | blue (?{$c|=1}) }x; foreach my $line (@lines) { $c = 0; next if () = $line =~ /$regex/g, $c != 5; # bail on: !(red && bl +ue) | green # do something here, got red/blue combo }
Regards
mwa
|
|---|