I have json data that has unescaped quotes in the data. When I try to escape the quotes re.sub always double escapes the quotes. I think it is trying to escape the escape backslash.
I’m doing a look back to be sure the quotes are not already escaped.
sample_data = 'sometimes called "rainbow lattice sunstone," features'
escaped_text = re.sub(r'(?<!\)"', r'"', sample_data)
I expect escaped_text to be sometimes called "rainbow lattice sunstone," features
however it is
sometimes called \"rainbow lattice sunstone,\" features