Skip to content

Instantly share code, notes, and snippets.

@ivanvanderbyl
Forked from toolmantim/sepThousands.js
Created May 18, 2010 13:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ivanvanderbyl/404980 to your computer and use it in GitHub Desktop.
Save ivanvanderbyl/404980 to your computer and use it in GitHub Desktop.
// A Javascript version of Allan Odgaard's thousands separator regex
// http://blog.macromates.com/2007/recursion-in-regular-expressions/
123456789.toString().replace(/(\d{1,3})(?=(\d{3})+(?!\d))/g, '$1,');
// => "123,456,789"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment