Regex - Match Entire String Unless

Viewed 9260

I need to write a regular expression that will match everything in the string unless it has a certain word in it. Taking this string for example:

http://12.34.567.890/sqlbuddy

The expression that matches everything is:

^.*$

...Which needs to be modified so that it will not match the string at all if it contains the word "sqlbuddy". I thought that a negative lookahead would do it, but that's not working for me.

For example, I tried this, which doesn't work:

^(?!sqlbuddy).*$

How should I modify this?

3 Answers
Related