title: Regex for matching something if it is not preceded by something else
body: <p>With regex in Java, I want to write a regex that will match if and only if the pattern is not preceded by certain characters. For example:</p>
  <pre><code>String s = &quot;foobar barbar beachbar crowbar bar &quot;;
  </code></pre>
  <p>I want to match if <code>bar</code> is not preceded by <code>foo</code>. So the output would be:</p>
  <pre><code>barbar
  beachbar
  crowbar
  bar
  </code></pre>