title: Python RegEx, match words in string and get count
body: <p>I want to match a list of words with an string and get how many of the words are matched. </p>
  
  <p>Now I have this:</p>
  
  <pre><code>import re
  words = ["red", "blue"]
  exactMatch = re.compile(r'\b%s\b' % '\\b|\\b'.join(words), flags=re.IGNORECASE)
  print exactMatch.search("my blue cat")
  print exactMatch.search("my red car")
  print exactMatch.search("my red and blue monkey")
  print exactMatch.search("my yellow dog")
  </code></pre>
  
  <p>My current regex will match the first 3, but I would like to find out how many of the words in the list <code>words</code> that matches the string passed to <code>search</code>. Is this possible <strong>without</strong> making a new <code>re.compile</code> for each word in the list?</p>
  
  <p>Or is there another way to achieve the same thing?</p>
  
  <p>The reason I want to keep the number of <code>re.compile</code> to a minimum is <strong>speed</strong>, since in my application I have multiple word lists and about 3500 strings to search against.</p>