While regex can be simplified:
/\{("(?:[^\\"]+|\\.)*")(?=,)|,("(?:[^\\"]+|\\.)*")(?=,)|,("(?:[^\\"]+|\\.)*")(?=\})/g
To:
/{("(?:[^\\"]+|\\.)*")(?=,)|,("(?:[^\\"]+|\\.)*")(?=,)|,("(?:[^\\"]+|\\.)*")(?=})/g
Removing the escaping { and } , as this is not required for the JavaScript regex mechanism.
It is not possible to remove your explicit duplicate pattern ("(?:[^\\"]+|\\.)*") In JavaScript.
JavaScript does not support all the same regular expression functions that are supported by PCRE (PHP, C ++, Perl, etc.).
For example, in PHP / C ++ you can do this:
{("(?:[^\\"]+|\\.)*")(?=,)|,((?1))(?=,)|,((?1))(?=})
For Perl 5.22, you will need to avoid this again { so that it looks something like this:
m/\{("(?:[^\\"]+|\\.)*")(?=,)|,((?1))(?=,)|,((?1))(?=})/g
This (?1) is a subroutine call to match the regular expression within capture group 1 , which in this case is ("(?:[^\\"]+|\\.)*") .