replace character in string python with expression 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))
# ABC@xxx.com ABC@yyy.com ABC@zzz.com