title: Matching terms that contain special characters with re.findall()?
body: <p>Using <code>re.findall()</code>, I'm attempting to find all occurrences of each term from a list of terms, in a string.</p>
  
  <p>If a particular term contains special characters (i.e. <code>a '+'</code>), a match will not be found, or error messages may be generated. Using <code>re.escape()</code>, the error messages are avoided, but the terms with special characters are not found within the string. </p>
  
  <pre><code>import re         
  my_list = ['java', 'c++', 'c#', '.net']
  my_string = ' python javascript c++ c++ c# .net java .net'
  matches = []
  
  for term in my_list:
      if any(x in term for x in ['+', '#', '.']):
          term = re.escape(term)
  
      print "\nlooking for term '%s'" % term 
      match = re.findall("\\b" + term + "\\b", my_string, flags = re.IGNORECASE)
      matches.append(match)
  </code></pre>
  
  <p>The above code will only find 'java' within the string. 
  Any suggestions regarding, how to find terms with special characters within the string?</p>
  
  <p><strong>Caveat</strong>: I cannot change 'my_list' manually, because I don't know in advance what terms it will contain.</p>
  
  <p><strong>Update</strong> - it appears that the problem has to do with the word boundary specifiers within the regex (the "\b") breaking up the string along characters which include the non-alphanumeric chars included in the string. It's unclear how to solve this in a clean and straightforward way, however.</p>
  
  <p><strong>Edit</strong> - this question is not a duplicate of <a href="https://stackoverflow.com/questions/18935754/how-to-escape-special-characters-of-a-string-with-single-backslashes">this</a> - it already incorporates the most applicable solution from that post.</p>