Is there a way to add some text after pattern in python string?
For example I can do it easily with sed:
sed 's/my [a-z]\+ pattern/& lost_text/'
where & means the whole matched pattern.
search and man pages didn't help me :(
You're looking for re.sub:
Example:
>>> import re
>>> re.sub(r'(\d+)',r'\1--','abcd1cf123vf')
'abcd1--cf123--vf'