import re s = "Example String" replaced = re.sub('[ES]', 'a', s) print replaced # will print 'axample atring'