Someone at experts-exchange told me the solution.
See this example:
([^ ]*) (?!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
On Aug 30, 3:44 pm, Jake <jake.du... gmail.com> wrote:
> I want a regex to return a match for a pattern
specifying "does not
> contain this phrase".
>
> 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!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Regex" group.
To post to this group, send email to regex googlegroups.com
To unsubscribe from this group, send email to
regex-unsubscribe googlegroups.com
For more options, visit this group at http://groups.go
ogle.com/group/regex
-~----------~----~----~----~------~----~------~--~---
|