This is my string,
"Alexandra ""Alex""" I am trying to replace two adjacent double quotes with a /" so the result is something like this.
"Alexandra \"Alex\"" After this, I will append this string to an array. This looks very trivial, and I am able to do this with replace.
a = '"Alexandra ""Alex"""' x = a.replace('""', "\\\"") print x # prints "Alexandra \"Alex\"" res = [] res.append(x) print res # prints ['"Alexandra \\"Alex\\""'] When appending to another array it's escaping the forward slash again.
How can I remove the extra forward slash?