JavaScript如何使用正規表示式顯示數值千分位

n = "1279834847944074100465236.33";
re = /(\d{1,3})(?=(\d{3})+(?:$|\D))/g ;
n1 = n.replace(re,"$1,");

console.log(n + "\r\n" + n1);

Demo

您也可能喜歡這些文章

Copyright © 2018 ucamc