Python string.replace regular expression
str.replace() v2|v3 does not recognize regular expressions. To perform a substitution using a regular expression, use re.sub() v2|v3. For example: In a loop, it would be better to compile the regular expression first: