In this example we will show how to get the position (start- and end-position) of the first match occurrence when searching for a string in Python.
Source Code
import re
str1 = 'I love Python'
r = re.search('o', str1)
print(r.span())
Output:
(3, 4)