in reply to Boolean operators in PERL regexp?
I recommend against using these (a parser would work better), but here's a snippet from my scratchpad:
/^(?:(?!$re).)*$/ # NOT re /$re1|$re2/ # re1 OR re2 /^(?=.*$re1)(?=.*$re2)/ # re1 AND re2
NOT must be anchored on both ends, but it doesn't have to be with ^ and $.
AND doesn't have to be anchored, but if the start is anchored (with ^ or by some other means), it should speed up the case where there is no match.
The .* in AND may need to be replaced so it doesn't look too far ahead.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Boolean operators in PERL regexp?
by lenrobert (Initiate) on Feb 25, 2005 at 16:25 UTC | |
by ikegami (Patriarch) on Feb 25, 2005 at 16:30 UTC | |
by lenrobert (Initiate) on Feb 25, 2005 at 17:41 UTC |