in reply to Pattern matching
tom and (dick or harry or john)I'll assume you want to match a string containing "tom" and one (or more) of "dick","harry" or "john" in any order.
This can't be done easily in one regular expression, but you can use two (or more):
or/tom/ && /dick|harry|john/;
Note that && and || are perl operators, which don't have a corresponding meaning inside a regex. (You can use | in a regex, but there is no & operator, because regexes already match the whole expression by default)/tom/ && ( /dick/ || /harry/ || /john/ );
|
|---|