Open this example in the interactive library
Source code
import re
print([m.span() for m in re.finditer('cat', 'cat dog cat')])Sample output
[(0, 3), (8, 11)]

Find match offsets. A self-contained example using the Python standard library.
Open this example in the interactive library
import re
print([m.span() for m in re.finditer('cat', 'cat dog cat')])[(0, 3), (8, 11)]