title: Find a word in a string python using regex or other methods
body: <p>I am trying to go through an array of words and check if they exist in a string. I understand there are many options for doing this such as using re.search but I need to differ between some words (ie. Java vs Javascript)</p>
  
  <p>An example:</p>
  
  <pre><code>import re
  
  s = 'Some types (python, c++, java, javascript) are examples of programming.'
  words = ['python', 'java', 'c++', 'javascript', 'programming']
  
  for w in words:
      p = re.search(w, s)
      print(p)
  
  &gt;&gt;&lt;_sre.SRE_Match object; span=(12, 18), match='python'&gt;
  &gt;&gt;&lt;_sre.SRE_Match object; span=(20, 24), match='java'&gt;
  &gt;&gt;&lt;_sre.SRE_Match object; span=(20, 30), match='javascript'&gt;
  &gt;&gt;&lt;_sre.SRE_Match object; span=(48, 59), match='programming'&gt;
  </code></pre>
  
  <p>The above works to an extent but matches Java with Javascript.</p>
  
  <p>EDIT: Here was my solution</p>
  
  <pre><code>for w in words:
          regexPart1 = r"\s"
          regexPart2 = r"(?:!+|,|\.|\·|;|:|\(|\)|\"|\?+)?\s"
          p = re.compile(regexPart1 + re.escape(w) + regexPart2 , re.IGNORECASE)
          result = p.search(s)
  </code></pre>