如何给字符串加千分符?

箴水技术分享 . 发布于 2023-05-28 06:31:42 . 阅读 142
var rmb = 123456789.01
var retRmb = rmb.toFixed(2).replace(/\d{1,3}(?=(\d{3})+(\.\d*)?$)/g, '$&,'); 
console.log(retRmb);