📜  在javascript代码示例中将数字转换为印度卢比格式

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

代码示例1
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);