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
None of these worked
Example input:
foo<a href="anything">asdasd</a> bar
Example output:
foo\footnotemark bar
Assuming Python2 since You haven't mentioned anything about version
#/usr/bin/python
import re
# myfile is saved with utf-8 encoding
with open('myfile', 'r') as myfile:
text = myfile.read()
print text
data = re.sub('<a.+?</a>', r'\\footnotemark', text)
print data
outputs
foo<a href="anything">asdasd</a> bar
foo\footnotemark bar
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With