I\'ve searched for questions like this, but all the cases I found were solved in a problem-specific manner, like using !g in vi to negate the regex matches,
Try this regular expression:
^(?:(?!Foo).)*$
This will consume one character at a time and test if there is no Foo ahead. The same can be done with a negative look-behind:
^(?:.(?<!Foo))*$
But you can also do the same without look-around assertions:
^(?:[^F]*|F(?:$|[^o].|o(?:$|[^o])))*$
This matches any character except F or an F that is either not followed by a o or if followed by an o not followed by another o.