I have a string
"abc INC\","None", "0", "test"
From this string I want to replace any occurrence of backslash when it appears before " with a pipe |. I wrote the following code but it actually takes out " and leaves the \ behind.
import re
str = "\"abc INC\\\",\"None\", \"0\", \"test\""
str = re.sub("(\\\")", "|", str)
print(str)
Output: |abc INC\|,|None|, |0|, |test|
Desired Output: "abc INC|","None", "0", "test"
Can someone point out what am I doing wrong?
\\(?=")'to delimite your python string if there are"inside, it will be clearer to see what are your strings|"abc INC\|",|"None|", |"0|", |"test|"