When i changed two words in a string with other two words using re.sub i got the output. But when i tried that with numbers output is not coming correctly
>>> import re
>>> a='this is the string i want to change'
>>> re.sub('(.*)is(.*)want(.*)','\\1%s\\2%s\\3' %('was','wanted'),a)
'this was the string i wanted to change'
>>> re.sub('(.*)is(.*)want(.*)','\\1%s\\2%s\\3' %('was','12345'),a)
'this was\x8a345 to change'
>>>
i don't know why this happens could u please tel me how to use this Thanks in advance