title: Javascript: Replace Pipe with Commas in a packet
body: <p>I have string for example like this:</p>
  
  <pre><code>$K,86107,2,2,04,77.232323,86.330234,00000000000000,V,0,10,,,0,0,410,04,1e29,a16d,7000,0,1537|0|0|4762|0|0,1,0,,,,*22
  </code></pre>
  
  <p>If I use : <code>str.replace('|',",")</code> 
  it only replaces the first pipe with comma.</p>
  
  <p>If I use : <code>str.replace(/|/g,",")</code> the resulting string is:</p>
  
  <pre><code>,$,K,,,8,6,1,0,7,,,2,,,2,,,0,4,,,7,7,.,2,3,2,3,2,3,,,8,6,.,3,3,0,2,3,4,,,0,0,0,0,0,0,0,0,0,0,0,0,0,0,,,V,,,0,,,1,0,,,,,,,0,,,0,,,4,1,0,,,0,4,,,1,e,2,9,,,a,1,6,d,,,7,0,0,0,,,0,,,1,5,3,7,|,0,|,0,|,4,7,6,2,|,0,|,0,,,1,,,0,,,,,,,,,*,
  </code></pre>
  
  <p>What I want is:</p>
  
  <pre><code>$K,86107,2,2,04,77.232323,86.330234,00000000000000,V,0,10,,,0,0,410,04,1e29,a16d,7000,0,1537,0,0,4762,0,0,1,0,,,,*22
  </code></pre>
  
  <p>Any suggestions?</p>