title: Is it possible to find specified substrings in a string in one iteration or faster then O(n*m)?
body: <p>I have a string and list of unique substrings. The problem is to identify, which substrings occur in our string.</p>
  <p>It can be done simply with 2 nested loops.</p>
  <pre class="lang-py prettyprint-override"><code>result = []
  substrings = ['foo', 'bar', 'spam', 'eggs']
  text = 'foo123123spameggsabcde'
  
  for s in substrings:
      if s in text:
          result.append(s)
  </code></pre>
  <p>But it is slow, especially whith long string and many substrings. Is there a way to perform this more efficiently?</p>