Unable to use regex to isolate commas outside quotes

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Gabriel Lima
:warning: Old Version Published before Godot 3 was released.

Hi, I’m trying to make a script to make the output of the Dictionary.to_json in a human readable JSON format, instead of the current single line output.
I’m currently stuck on finding only the commas that are not inside quotes. I found this RegEx that should be able to do this:
Regex101 test
The example text is exactly my current test json in use.
Since Godot don’t work with regex literals, we have to escape some things and put inside quotes, so I believe I need this:


However, this is currently capturing all commas regardless of quotes, resulting on this newline on the wrong place: Results
Am I missing something or is there something broken with the RegEx? I tried searching issues on github and the Godot Q&A section and found nothing so far.
Thanks in advance, if I manage to find a solution I’ll post here.

:bust_in_silhouette: Reply From: dodgyville

This regex splits on commas but maintains integrity of quotes for me in python, it might be of help?

re.split(r', (?=(?:"[^"]*?(?: [^"]*)*))|, (?=[^",]+(?:,|$))', myStr)