Reputation: 468
I am working on jquery slider to take min and max price and I need help to insert space before
each 3 zeros.
for example:
I need 5000 to become 5 000
50000 = 50 000
Can you help me? Thanks alot
Upvotes: 0
Views: 398
Reputation: 183602
You could write:
var splitIndex = (s.length + 2) % 3 + 1;
s = s.substr(0, splitIndex) + s.substr(splitIndex).replace(/\d\d\d/g, ' $&');
Upvotes: 2