The Python function re.sub(pattern, replacement, string) returns the modified string with the matched pattern replaced with the replacement. Is there any easy w
re.sub(pattern, replacement, string)
Depends on the version. In <= 2.6, you have to couple sub() with match() or search() to get count.
sub()
match()
search()
If you are using Python 2.7, you can use subn(), which will return a tuple of (new_string, number_of_subs_made).
subn()
Not sure about 3+.