python regex replace characters in string code example
Example 1: python regex substitute
import re
s = "Example String"
replaced = re.sub('[ES]', 'a', s)
print replaced
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]