title: What is efficient way to match words in string?
body: <p>Example:</p>
  <pre><code>names = ['James John', 'Robert David', 'Paul' ... the list has 5K items]
  
  text1 = 'I saw James today'
  text2 = 'I saw James John today'
  text3 = 'I met Paul'
  
  is_name_in_text(text1,names)   # this returns false 'James' in not in list
  is_name_in_text(text2,names)   # this returns 'James John'
  is_name_in_text(text3,names)   # this return 'Paul'
  </code></pre>
  <p><code>is_name_in_text()</code> searches if any of the name list is in text.</p>
  <p>The easy way to do is to just check if the name is in the list by using <code>in</code> operator, but the list has 5,000 items, so it is not efficient. I can just split the text into words and check if the words are <code>in</code> the list, but this not going to work if you have more than one word matching. Line number 7 will fail in this case.</p>