Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: quick regex help for multiple OR

by mwah (Hermit)
on May 13, 2008 at 17:34 UTC ( [id://686325]=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://686325]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (9)
As of 2024-03-28 10:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found