Is it possible to use NOT in a regular expression in TextMate

regextextmate

I have a Matlab project which I'm working on in the OSX editor TextMate. I need to find all instances of a certain word, let's say it's "foo", that is not either preceded by a "." or succeeded by a "/".

However, I cannot find any way to search for regular expressions that are negatively defined like this. Does anyone know if it is possible to search for something like "A preceded by anything other than B"?

(TextMate uses the Oniguruma regular expression library by K. Kosako.)

Best Answer

You want to use this bit of the syntax:

(?=subexp)         look-ahead
(?!subexp)         negative look-ahead
(?<=subexp)        look-behind
(?<!subexp)        negative look-behind

In your case, (?<!\.)foo(?!/)