This is the code I'm using to try to replace empty commas with zero:
let str = '<C><P /><Z><S><S P=",,0.3,0.2,,,," L="195" X="256" H="32" Y="306" T="0" /><S P=",,0.3,0.2,,,," L="146" X="587" H="87" Y="257" T="0" /><S P=",,0.3,0.2,,,," L="50" X="333" H="45" Y="82" T="0" /></S><D /><O /></Z></C>';
let repl = str.replace(/,,/g, ",0,");
The result is:
<C><P /><Z><S><S P=",0,0.3,0.2,0,,0," L="195" X="256" H="32" Y="306" T="0" /><S P=",0,0.3,0.2,0,,0," L="146" X="587" H="87" Y="257" T="0" /><S P=",0,0.3,0.2,0,,0," L="50" X="333" H="45" Y="82" T="0" /></S><D /><O /></Z></C>
I expected something like:
<... P="0,0,0.3,0.2,0,0,0,0" .../>
How to do it?