Python ProgrammingPython Programming

How to find all occurrences of a substring?

import re

aString = 'this is a string where the substring "is" is repeated several times'
print([(a.start(), a.end()) for a in list(re.finditer('is', aString))])
Output
[(2, 4), (5, 7), (38, 40), (42, 44)]