title: Python re: negating part of a regular expression
body: <p>Perhaps a silly question, but though google returned lots of similar cases, I could not find this exact situation: what regular expression will match all string NOT containing a particular string. For example, I want to match any string that does not contain 'foo_'.
  Now,</p>
  
  <pre><code> re.match('(?&lt;!foo_).*', 'foo_bar') 
  </code></pre>
  
  <p>returns a match. While</p>
  
  <pre><code>re.match('(?&lt;!foo_)bar', 'foo_bar')
  </code></pre>
  
  <p>does not.
  I tried the non-greedy version:</p>
  
  <pre><code> re.match('(?&lt;!foo_).*?', 'foo_bar')
  </code></pre>
  
  <p>still returns a match. 
  If I add more characters after the ),</p>
  
  <pre><code>re.search('(?&lt;!foo_)b.*', 'foo_bar')
  </code></pre>
  
  <p>it returns None, but if the target string has more trailing chars:</p>
  
  <pre><code>re.search('(?&lt;!foo_)b.*', 'foo_barbaric')
  </code></pre>
  
  <p>it returns a match.
  I intentionally kept out the initial .* or .*? in the re. But same thing happens with that.</p>
  
  <p>Any ideas why this strange behaviour? (I need this as a single regular expression - to be entered as a user input). </p>