title: Find all occurrences of a substring (including overlap)?
body: <p>Okay, so I found this: <a href="https://stackoverflow.com/questions/4664850/find-all-occurrences-of-a-substring-in-python">How to find all occurrences of a substring?</a></p>
  <p>Which says, to get the indices overlapping occurances of substrings in a list, you can use:</p>
  <p><code>[m.start() for m in re.finditer('(?=SUBSTRING)', 'STRING')]</code></p>
  <p>Which works, but my problem is that both the string and the substring to look for are defined by variables. I don't know enough about regular expressions to know how to deal with it - I can get it to work with non-overlapping substrings, that's just:</p>
  <p><code>[m.start() for m in re.finditer(p3, p1)]</code></p>
  <p>Edit:</p>
  <p>Because someone asked, I'll go ahead and specfify. p1 and p3 could be any string, but if they were, for example <code>p3 = &quot;tryt&quot;</code> and <code>p1 = &quot;trytryt&quot;</code>, the result should be <code>[0, 3]</code>.</p>