title: How to use re with beautifulsoup in python 2.7 to suppress certain results?
body: <p>I'm trying to use beautifulsoup and re to grab a list of URLs, but I want to suppress one of the results and I can't figure out how to do so. </p>
  
  <p>This code gets me 29 (of 35) URLs: </p>
  
  <pre><code>issue_index = soup.find_all('a', href=re.compile('past'))
  </code></pre>
  
  <p>That's one too many. </p>
  
  <p>One of the URLs has <code>target="_blank"</code>, and I would like to exclude this URL from the others. </p>
  
  <p>However, I can't figure out how to do it. </p>
  
  <p>This does the exact opposite of what I want, returning only the URL I want to discard. </p>
  
  <pre><code>issue_index = soup.find_all('a', href=re.compile('past'), target="_blank")
  </code></pre>
  
  <p>This code removes the bad URL (with the target attribute), but it doesn't filter the list with the regular expression. </p>
  
  <pre><code>def remove(a):
      return a.has_attr('href') and not a.has_attr('target')
  
  issue_index = soup.find_all(remove)
  </code></pre>
  
  <p>It's so maddening. </p>