Get to Know re.sub()
In Python, leveraging regex usually means to use the
re module. In your particular case, you’ll use
re.sub() to substitute a string with a string based on a regex pattern that is part of your arguments.
If the pattern isn’t found,
string is returned unchanged. The optional argument
count defines the maximum number of pattern occurrences to be replaced. If omitted or zero, all occurrences will be replaced.
Become a Member to join the conversation.