Insert whitespace after every 3 character in a string Javascript : <p>I need to display a price in a format like</p>

<pre><code>7
70 
700
700 000
70 000
700 000
7 000 000 etc
</code></pre>

<p>The problem is that I receive the price from json file, so it's always a string. </p>

<p>What I want is to convert that price string into the desired format by RegEx.</p>

<ol>
<li>We invert the price <code>7000000 = 0000007</code></li>
<li>We put a whitespace after 3rd character in the inverted string <code>000 000 7</code></li>
<li>Then we invert the string again and get a normal price format <code>7 000 000</code></li>
</ol>

<p>Is it possible for json data and perhaps there is a more correct way to go? Didn't find any working examples.</p>
