import re
str = re.sub(regex, repl, str)

re.sub returns a copy of replaced str, so, remember to assign it back