给金额添加千分位
作者:互联网
"123456789" => 123,456,789
'123456789'.replace(/(?=\B(?:\d{3})+$)/g, ',') '123456789'.replace(/(?=\B(?:\d{3})+$)/g, ',') '123456789'.replace(/(?=(?!\b)(?:\d{3})+$)/g, ',') '123456789'.replace(/\B(?=(?:\d{3})+$)/g, ',') '123456789'.replace(/(?!\b)(?=(?:\d{3})+$)/g, ',') '123456789'.replace(/(?!^)(?=(?:\d{3})+$)/g, ',') '123456789'.replace(/(?=(?!^)(?:\d{3})+$)/g, ',')
"123456789 123456789 " => 123,456,789 123,456,789
'123456789 123456789 '.replace(/(?=\B(?:\d{3})+\b)/g, ',') '123456789 123456789 '.replace(/(?=(?!\b)(?:\d{3})+\b)/g, ',') '123456789 123456789 '.replace(/\B(?=(?:\d{3})+\b)/g, ',') '123456789 123456789 '.replace(/(?!\b)(?=(?:\d{3})+\b)/g, ',')
1888 => $ 1888.00
188..toFixed(2).replace(/(?!^)(?=(?:\d{3})+\b)/g, ',').replace(/^/, "$")
标签:123,金额,千分,456,replace,789,添加,123456789 来源: https://www.cnblogs.com/ccbabi/p/10404674.html