I am trying to read a file and replace every "a ... a" by a '\footnotemark'
with open('myfile', 'r') as myfile:
   data = myfile.read()
   data = re.sub('<a.+?</a>', '\footnotemark', data)
Somehow Python always makes '\footnotemark' to '\x0cootnotemark' ('\f' to '\x0c'). I tried so far
- Escaping: '{2 Backslashes}footnotemark'
- raw String: r'\footnotemark' or r'"\footnotemark"'
None of these worked
Example input:
foo<a href="anything">asdasd</a> bar
Example output:
foo\footnotemark bar
r'\\footnotemark'\\footnotemarkr'\\footnotemark'is the required string; alternatively:'\\\\footnotemark'. That's because 2 levels of escaping are required, one level for Python itself, one level for the regex syntax. FWIW,\fis a formfeed, i.e., a page-break control character.