For example, if I have the phrase "good little dawg", and the target
string "Hey dude", the regex has to return something (with the
find() ), but not with "I have a good little dawg in my house".
I have tried something akin to [^(good little dawg)], but it doesn't
work all the time.
In other words, I need a match if the phrase is *not* in the target
string.
Any idea?
Thanks!
([^ ]*) (?!world)([^.]*)
this will match "hello will", but not "hello world".
I didn't find much documentation about it, but you can experiment with
these patterns:
(?=X) X, via zero-width positive lookahead
(?!X) X, via zero-width negative lookahead
(?<=X) X, via zero-width positive lookbehind
(?<!X) X, via zero-width negative lookbehind
http://java.sun.com/j2se/1.5.0/docs/api/java/util/regex/Pattern.html
DAvid