Created
June 25, 2011 05:15
-
-
Save jhartikainen/1046179 to your computer and use it in GitHub Desktop.
Format a numeric string every three numbers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Is this abuse of array functions? :D | |
'20000001'.split('').reverse().join('').match(/\d{3}|\d+$/g).map(function(s){ return s.split('').reverse().join(''); }).reverse().join(' '); | |
//produces "20 000 001" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yep that might be a bit more practical :)