Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

js实现千位分隔符 #9

Open
chess99 opened this issue Oct 10, 2019 · 1 comment
Open

js实现千位分隔符 #9

chess99 opened this issue Oct 10, 2019 · 1 comment

Comments

@chess99
Copy link

chess99 commented Oct 10, 2019

var result = "123456789".replace(/(?=(\B\d{3})+$)/g, ",");
console.log(result);
// => "123,456,789"
@9a-aaaaaaaa
Copy link

var result = "123456789".replace(/(?=(\B\d{3})+$)/g, ",");
console.log(result);
// => "123,456,789"

@chess99

const regEx = /(?!^)(?=(\d{3})+$)/g;
这样子也可以

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants