In this example we will show how to get a match object when searching for a string in Python.
Source Code
import re
str1 = 'I love Python'
r = re.search('o', str1)
print(r)
Output:
<re.Match object; span=(3, 4), match='o'>
In this example we will show how to get a match object when searching for a string in Python.
import re
str1 = 'I love Python'
r = re.search('o', str1)
print(r)
Output:
<re.Match object; span=(3, 4), match='o'>