Python 2.7. I'm trying to replace a string with a new string. This is the code:
somestring = "C:\xampp\htdocs\email\BLAHBLAH"
thestring = somestring
thenewstring = thestring.replace("C:\\xampp\\htdocs\\email\\BLAHBLAH", "something")
print thestring
print thenewstring
What I want to see printed:
C:\xampp\htdocs\email\BLAHBLAH
something
This is the error I'm getting:
ValueError: invalid \x escape
EDIT: Let's pretend that I have no access to do anything at all with the top line. It is set in stone. I'm reading in meta data from a Word document and looking for that exact string and then trying to replace it with a new string. My code's involvement starts on line 2. It is not a duplicate of that question because I am not working with a literal string. I've read through quite a few question/answers on here and I'm understanding that "\x" is some kind of special thing that replace can't find for reasons I don't understand. I've tried several of the suggestions (like using "repr", or "decode") but I can't get any of them to work.
How can I get this to work?