I am trying to replace all : by = except the : inside the quotes. In other words: replace all : which are not surrounded by "something and something".
# input
x:123; y:"z:456"
# desired output
x=123; y="z:456"
I tried to solve this using negative lookbehind/lookahead, but I cannot match the text surrounding the : in the quotes, as quantifiers are not allowed in the lookbehind; so this does not work:
re.sub(r'(?<!".+?):(?!.+?")', '$')
Can this be done using regex at all?
Thanks!