regex expresion in replace python code example
Example 1: python replace regex
import re
s = "Example String"
replaced = re.sub('[ES]', 'a', s)
print replaced
# will print 'axample atring'
Example 2: replacing a value in string using aregular expression pyhton
import re
s = '[email protected] [email protected] [email protected]'
print(re.sub('[a-z]*@', 'ABC@', s))
# [email protected] [email protected] [email protected]