subject = 'a " b \\" c \\\\" d "\\\\" e " f';print(subject);result = subject.replace(/([^"\\]*(?:\\.[^"\\]*)*)"/g, '$1\\"');print(result);
Standard input is empty
a " b \" c \\" d "\\" e " f a \" b \" c \\\" d \"\\\" e \" f
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!