I have a string in json formation like that
{"1":"abc"abc"abc","2":"xyz"xyz"xyz"}
But if I want to tranform it into json data, I need to remove '"' between '"' and get a string like below
{"1":"abcabcabc","2":"xyzxyzxyz"}
I tried using re.sub to do that, but failed. Anyone could help me with that? My script is below:
a='{"1":"abc"de"fg","2":"xyz"xyz"xyz"}'
r = re.compile(r'(?<!\:)(?<=.+)"|(?<!,)"|"(?!}|,)')
b = r.sub('', a)
print(b)
When I ran the script, the outcome is below:
Traceback (most recent call last):
File "./_t1.py", line 5, in <module>
r = re.compile(r'(?<!\:)(?<=.+)"|(?<!,)"|"(?!}|,)')
File "/home/emc/ssd/anaconda3/lib/python3.6/re.py", line 233, in compile
return _compile(pattern, flags)
File "/home/emc/ssd/anaconda3/lib/python3.6/re.py", line 301, in _compile
p = sre_compile.compile(pattern, flags)
File "/home/emc/ssd/anaconda3/lib/python3.6/sre_compile.py", line 566, in compile
code = _code(p, flags)
File "/home/emc/ssd/anaconda3/lib/python3.6/sre_compile.py", line 551, in _code
_compile(code, p.data, flags)
File "/home/emc/ssd/anaconda3/lib/python3.6/sre_compile.py", line 187, in _compile
_compile(code, av, flags)
File "/home/emc/ssd/anaconda3/lib/python3.6/sre_compile.py", line 160, in _compile
raise error("look-behind requires fixed-width pattern")
sre_constants.error: look-behind requires fixed-width pattern