Python re.sub back reference not back referencing

Viewed 27153

I have the following:

<text top="52" left="20" width="383" height="15" font="0"><b>test</b></text>

and I have the following:

fileText = re.sub("<b>(.*?)</b>", "\1", fileText, flags=re.DOTALL)

In which fileText is the string I posted above. When I print out fileText after I run the regex replacement I get back

<text top="52" left="20" width="383" height="15" font="0"></text>

instead of the expected

<text top="52" left="20" width="383" height="15" font="0">test</text>

Now I am fairly proficient at regex and I know that it should work, in fact I know that it matches properly because I can see it in the groups when I do a search and print out the groups but I am new to python and am confused as to why its not working with back references properly

1 Answers
Related