Regexp in Javascript: replace minus with comma+minus when condition is met
<p>I need to replace <code>\-</code> minus with <code>\,+-</code> comma+minus when space/no-space/comma before the minus. In a SVG path I found this:</p>

<pre><code>`201.86-38.778` 
</code></pre>

<p>and I need to make it </p>

<pre><code>`201.86,-38.778`.
</code></pre>

<p>I tried <code>str.replace(/-/g,'\,-')</code> but this creates additional commas when not needed.</p>

<p><strong>Update</strong>, I also need this to work like this:</p>

<pre><code>`201.86 -38.778` // notice the space
</code></pre>

<p>to make it </p>

<pre><code>`201.86,-38.778`.
</code></pre>