I need to replace \
into \\
with python from pattern matching.
For example, $$\a\b\c$$
should be matched replaced with $$\\a\\b\\c$$
.
I couldn't use the regular expression to find a match.
>>> import re
>>> p = re.compile("\$\$([^$]+)\$\$")
>>> a = "$$\a\b\c$$"
>>> m = p.search(a)
>>> m.group(1)
'\x07\x08\\c'
I can't simply make the input as raw string such as a=r'$$\a\b\c$$'
because it's automatically processed with markdown processor.
I also found that I couldn't use replace method:
>>> a.replace('\\','\\\\')
'$$\x07\x08\\\\c$$'
How can I solve this issue?