vertito wrote:
>  /[\s']((mountain.*clouds)|(clouds.*mountain))[\s',-]/i
>
> great, the above works on making "mountain" and "clouds" both true.
>
> does the below differs from the above?
>
> /\bmountain\b|\bclouds\b/i
>   

Absolutely. That second string is an OR operation.  It will match
mountain, OR clouds, and requires a "word boundary" at the beginning and
end. You need a whitespace, punctuation mark, or end/beginning of
string. ie: it won't match "cloudspray" or "airmountain", but will match
"mountain, " or "-clouds".

It's actually quite similar to how your CF_BAD_SUBJ12 would work if you
removed the errant \ in front of the |. However, there are some subtle
differences in what boundaries this rule will accept. It requires a
specific set of possible boundaries, and isn't zero-width so it won't
match anything starting with "mountain" or "clouds".


Really in regexes there is no such thing as an AND operation. It's just
not something natural to do in a regex.

So in the first chunk, John faked an And. What you really have is two
expressions that are ORed together.

(mountain.*clouds) will match anything containing mountain, followed by
clouds, with any number of characters in between them (.*).

(clouds.*mountain) will look for clouds first..

By ORing the two together, you've got the equivalent of an AND, because
it will match anything containing both words, no matter which order they
come in.

Reply via email to