title: A regex to match a substring that isn't followed by a certain other substring
body: <p>I need a regex that will match <code>blahfooblah</code> but not <code>blahfoobarblah</code></p>
  
  <p>I want it to match only foo and everything around foo, as long as it isn't followed by bar.</p>
  
  <p>I tried using this: <code>foo.*(?&lt;!bar)</code> which is fairly close, but it matches <code>blahfoobarblah</code>. The negative look behind needs to match anything and not just bar.</p>
  
  <p>The specific language I'm using is Clojure which uses Java regexes under the hood.</p>
  
  <p>EDIT: More specifically, I also need it to pass <code>blahfooblahfoobarblah</code> but not <code>blahfoobarblahblah</code>.</p>