function splitNum(str){ if(!str){ return ""; } var strArr = (str+"").split("").reverse().join("").replace(/(\d{3})/g,"$1,").split("").reverse(); strArr[0] == "," && (strArr[0] = ""); return strArr.join("");
3位分割,传入需要分割的数字即可
时间: 2024-10-16 08:12:23
function splitNum(str){ if(!str){ return ""; } var strArr = (str+"").split("").reverse().join("").replace(/(\d{3})/g,"$1,").split("").reverse(); strArr[0] == "," && (strArr[0] = ""); return strArr.join("");
3位分割,传入需要分割的数字即可