I want to replace the content of a string using regex in python.
I have tried the following code:
regex=r"(?:ab*)\w+"
text ="absd 2013 abpq ab 123absd"
pattern=re.compile(regex)
print pattern.sub("dummy",text)
I got the output like this:
dummy 2013 dummy dummy 123dummy
But my actual text is still same.
Can I modify the text itself with a regex?