FEGuide icon indicating copy to clipboard operation
FEGuide copied to clipboard

js实现千位分隔符

Open chess99 opened this issue 5 years ago • 1 comments

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

chess99 avatar Oct 10 '19 03:10 chess99

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

@chess99

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

9a-aaaaaaaa avatar Dec 20 '20 03:12 9a-aaaaaaaa