mdn的正则文档
https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Guide/Regular_Expressions
js正则表达式的分组匹配
https://www.cnblogs.com/wancheng7/p/8906015.html
js的replace方法
https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/String/replace
js实现家千分位符
https://www.cnblogs.com/lvmylife/p/8287247.html

// 数字加千分位
export function formatThousandSeparator (num) {
    // 整数加千分位
    // const reg = /\d{1,3}(?=(\d{3})+$)/g;
    // return (num + '').replace(reg, '$&,');

    // 浮点数加千分位
    return (num  + '').replace(/\d{1,3}(?=(\d{3})+(\.\d*)?$)/g, '$&,');
}

相关文章:

  • 2021-06-12
  • 2022-12-23
  • 2022-01-31
  • 2022-12-23
  • 2021-12-09
  • 2022-12-23
  • 2022-01-16
  • 2021-05-18
猜你喜欢
  • 2022-02-26
  • 2022-12-23
  • 2021-12-20
  • 2022-12-23
  • 2021-06-13
  • 2021-10-16
  • 2022-12-23
相关资源
相似解决方案