ConvertToNumber(str)
{
return str.replace(/[^0-9]/ig,"")
},
ConvertToTxt(num)
{
let res=num.toString().replace(/\d+/, function(n){ // 先提取整数部分
return n.replace(/(\d)(?=(\d{3})+$)/g,function($1){
return $1+",";
});
})
return res;
}
ConvertToNumber(str)
{
return str.replace(/[^0-9]/ig,"")
},
ConvertToTxt(num)
{
let res=num.toString().replace(/\d+/, function(n){ // 先提取整数部分
return n.replace(/(\d)(?=(\d{3})+$)/g,function($1){
return $1+",";
});
})
return res;
}
本文标题:长数字显示分隔
本文链接:https://www.haomeiwen.com/subject/nmdgphtx.html
网友评论