Created
December 7, 2016 14:46
-
-
Save goldnetonline/a8ef45dcf956b3b116fbed3dc80653d6 to your computer and use it in GitHub Desktop.
Add Thousand Separator
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
function _addThousandSep(n){ | |
var rx= /(\d+)(\d{3})/; | |
return String(n).replace(/^\d+/, function(w){ | |
while(rx.test(w)){ | |
w= w.replace(rx, '$1'+thousandSeparator+'$2'); | |
} | |
return w; | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment