Source Code:
(back to article)
import re string = "The quick brown fox jumps over the lazy dog." # Replace all occurrences of "the" with "a" using a regular expression new_string = re.sub("the", "a", string) print(new_string)
Result:
Report an issue