import re

string = """This ain't funny, you know.
But this escaped one (\") won't change."""

rx = re.compile(r'''(?<!\\)(["'])''')

string = rx.sub(r'\\\1', string)
print(string)