Skip to content

Instantly share code, notes, and snippets.

@hao-ji-xing
Created July 17, 2013 10:21
Show Gist options
  • Save hao-ji-xing/6019402 to your computer and use it in GitHub Desktop.
Save hao-ji-xing/6019402 to your computer and use it in GitHub Desktop.
给数字添加逗号
'3423112'.replace(/\d(?=(?:\d{3})+$)/g,'$&,')
"3,423,112"
'3423112'.replace(/(?!^)(?=(?:\d{3})+$)/g,',')
"3,423,112"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment