Python regex experts! I am trying to change a string in an XML document. Source line:
<Tag name="low" Value="%hello%\dir"/>
The result I want to see:
<Tag name="low" Value="C:\art"/>
My unsuccessful direct jump attempt:
lines = re.sub("%hello%\dir"", "C:\art"/>
This does not work. Changes nothing in the document. Something with%?
For testing purposes, I tried:
lines = re.sub("dir", "C:\art", a)
And I get:
<Tag name="low" Value="%hello%\C:BELrt"/>
The problem is that \ a = BEL .
I tried a bunch of other things, but to no avail. How do I solve this problem?
source share