function formatNum(strNum) {

if (strNum.length <= 3) {

return strNum;

}

if (!/^(\+|-)?(\d+)(\.\d+)?$/.test(strNum)) {

return strNum;

}

var a = RegExp.$1, b = RegExp.$2, c = RegExp.$3;

var re = new RegExp();

re.compile("(\\d)(\\d{3})(,|$)");

while (re.test(b)) {

b = b.replace(re, "$1,$2$3");

}

return a + "" + b + "" + c;

}

相关文章:

  • 2022-01-31
  • 2022-12-23
  • 2021-10-31
  • 2022-12-23
  • 2021-12-12
  • 2022-12-23
猜你喜欢
  • 2021-11-04
  • 2022-12-23
  • 2021-10-19
  • 2021-09-13
  • 2021-06-28
  • 2022-12-23
  • 2021-07-16
相关资源
相似解决方案