Skip to content

Instantly share code, notes, and snippets.

@andreyshr
Created August 2, 2018 07:43
Show Gist options
  • Save andreyshr/72f948f79a5e22e6cd68311748053102 to your computer and use it in GitHub Desktop.
Save andreyshr/72f948f79a5e22e6cd68311748053102 to your computer and use it in GitHub Desktop.
formatDigits(str)
function formatDigits(str) {
return str.toString().replace(/(\d)(?=(\d\d\d)+([^\d]|$))/g, '$1 ');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment