D.J. wrote: > OK, I'm stumped. I need to create a regex that will match if > anything other than two terms I've specified exist. > > So for example, I have two terms I like, say "cat" and "dog". I want > the rule to match if a string contains anything other than cat or > dog. > > I tried ... > > $value !~ /cat|dog/ > > ...but this had the unintended consequence of still matching a string > like "cat dog bird" or "cat bird" since the string does contain one > of my two terms. So what do I need to do? Thanks in advance!
I'm not quite clear on what you want here. Your example should NOT have matched on "cat dog bird" since it contains one of your terms. It would have matched on "bird", since it doesn't. If you want to match any string that doesn't include your terms, you do it just like you said. $value !~ /cat|dog/ If you want to match any string which does not exactly match your terms, do this: $value !~ /^(?:cat|dog)$/ This will match on anything other than "cat" or "dog". If this doesn't help, give us some more examples of things you expect to match and things you don't expect to match. -- Bowie