2

Possible Duplicate:
Javascript Thousand Separator / string format

My question is: How can i separate a number /1000; So i want to make "1243234" to "1 243 234" or "1000" to "1 000" etc. (sorry for my english=/)

Community
  • 1
  • 1
Bendegúz
  • 758
  • 7
  • 15
  • Take a look here: http://stackoverflow.com/questions/10809136/how-to-format-numbers-with-white-spaces-between-thousands – Irvin Dominin Jan 22 '13 at 16:42
  • you've got to be a little more specific, do you want to place the separator where the dots should be? – Jonathan DS Jan 22 '13 at 16:42
  • IMHO, this question isn't a duplication of the provided one. – sp00m Jan 22 '13 at 16:46
  • @sp00m: In my original comment, I had provided more links. The best dupe I've found (after voting) is [How to print a number thousands separators in JavaScript](http://stackoverflow.com/q/2901102/1048572) – Bergi Jan 22 '13 at 18:59

1 Answers1

4
> "1243234".replace(/\d(?=(\d{3})+$)/g, "$& ")
"1 243 234"
Bergi
  • 630,263
  • 148
  • 957
  • 1,375