📜  js 用逗号格式化印度价格 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:01:40.911000             🧑  作者: Mango

代码示例2
var x=12345678;
    x=x.toString();
    var lastThree = x.substring(x.length-3);
    var otherNumbers = x.substring(0,x.length-3);
    if(otherNumbers != '')
        lastThree = ',' + lastThree;
    var res = otherNumbers.replace(/\B(?=(\d{2})+(?!\d))/g, ",") + lastThree;
    alert(res);