Use Python’s string.replace vs re.sub

As long as you can make do with str.replace(), you should use it. It avoids all the pitfalls of regular expressions (like escaping), and is generally faster.

Leave a Comment