A regex to match a substring that isn't followed by a certain other substring.
- by Rayne
I need a regex that will match blahfooblah but not blahfoobarblah
I want it to match only foo and everything around foo, as long as it isn't followed by bar.
I tried using this: foo.*(?<!bar) which is fairly close, but it matches blahfoobarblah. The negative look behind needs to match baranything and not just bar.
The specific language I'm using is Clojure which uses Java regexes under the hood.