Rule Example: Simplify PCREs
Previous Microplanet Gravity Next |
Regular expressions can behave as an AND operator, if the words are in order. Consider two words:
· first · second
It is no problem to find the words in order:
Subject contains reg. expr. "first.+second"
But what if we want to match both words but in any order? The following PCRE form works for two words that occur in any order. Subject contains reg. expr. "(first.+second)|(second.+first)"
Not too bad, but if we have 3 or 4 words, it becomes difficult (to say the least!). Before you do that, remember that Gravity's rule (and advanced Filter) conditions make this easy:
Subject contains reg. expr. "first" AND Subject contains reg. expr. "second"
keep going:
AND Subject contains reg. expr. "third" AND Subject contains reg. expr. "fourth" AND Subject contains reg. expr. "fifth"
(note that this does not work if we want the words in order)
Negation
Simplify PCREs with Gravity's DOES NOT Contain ..
From contains reg. expr. "\bkirk\b" And From does not contain reg. expr. "\bspock\b"