In this example we will show how to replace the matches with the text of your choice using the sub() function in Python.
Source Code
import re
str1 = 'I love Python'
r = re.sub('o', 'O', str1)
print(r)
Output:
I lOve PythOn
In this example we will show how to replace the matches with the text of your choice using the sub() function in Python.
import re
str1 = 'I love Python'
r = re.sub('o', 'O', str1)
print(r)
Output:
I lOve PythOn