I didn't find out yet how to substitute any text (with re.sub or str.replace) when the text to be inserted is a single backslash ( \ ).
I tried this:
import re
cad = 'random\\text'
re.sub(r"\\\\", "\\", cad)
but i got:
raise error, v # invalid expression
error: bogus escape (end of line)
The pattern seems correct, as I checked on http://pythex.org/ The problem relies on the replacement. Any idea?