1import re
2s = "Example String"
3replaced = re.sub('[ES]', 'a', s)
4print replaced
5# will print 'axample atring'
1import re
2line = re.sub(r"</?\[\d+>", "", line)
3
4# Comented version
5line = re.sub(r"""
6 (?x) # Use free-spacing mode.
7 < # Match a literal '<'
8 /? # Optionally match a '/'
9 \[ # Match a literal '['
10 \d+ # Match one or more digits
11 > # Match a literal '>'
12 """, "", line)
13
1import re
2s = "Example String"
3replaced = re.sub('[ES]', 'a', s)
4print replaced