i

Python Programming

Search or Replace

RE method that has regular expressions is sub.

Below is Syntax:

RE.sub(patterns,repls,strings,max=0)

It replaces all occurrences of RE pattern in the string with repl, substituting all occurrences unless max. This method returns modified string.

Example

Live Demo