test1 = "<test>222</test>blah blah blah"
newVal = "222"
mstring = "(<test>).*(</test>)"
newString = re.sub(mstring,rf"\1{newVal}\2",test1)
print(newString)
I am trying to find a particular value in my string and substitute with a different string using re.sub function. Seems like i am find the correct match and replace is working however python is converting parts of the string into its ascii equivalent value. Can you help me with the above code so that i produce the below output please
<test>222</test>blah blah blah
instead i am getting below result
R2</test>blah blah blah