In this example we will show how to search the string to get the first occurrence of the match using the search() function in Python.
Source Code
import re
str1 = 'I love Python'
r = re.search('o', str1)
start_position = r.start()
print(start_position)
Output:
3