In [1]:
import re
In [2]:
s = 'aaa@xxx.com, bbb@yyy.com, ccc@zzz.net'
In [3]:
m = re.match(r'([a-z]+)@([a-z]+)\.com', s)
print(m)
In [4]:
result = re.sub(r'([a-z]+)@([a-z]+)\.com', 'new-address', s)
print(result)
In [5]:
p = re.compile(r'([a-z]+)@([a-z]+)\.com')
In [6]:
print(p)
In [7]:
print(type(p))
In [8]:
m = p.match(s)
print(m)
In [9]:
result = p.sub('new-address', s)
print(result)