How to find all intersections (also called the longest common substrings) of two strings and their positions in both strings?
For example, if S1=\"never\"
Batteries included!
The difflib module might have some help for you - here is a quick and dirty side-by-side diff:
>>> import difflib
>>> list(difflib.ndiff("never","forever"))
['- n', '+ f', '+ o', '+ r', ' e', ' v', ' e', ' r']
>>> diffs = list(difflib.ndiff("never","forever"))
>>> for d in diffs:
... print {' ': ' ', '-':'', '+':' '}[d[0]]+d[1:]
...
n
f
o
r
e
v
e
r