var a = '123,533.80';
a = a.replace(/,/g,'');
a = parseFloat(a) + 100;
function formats(num) {
var rgx = /(\d+)(\d{3})/,
x1 = num + "";
while (rgx.test(x1)) {
x1 = x1.replace(rgx, '$1' + ',' + '$2');
}
return x1
}
var newStr = formats(a.toFixed(2));
function formatMoney(s, type) {
if (/[^0-9\.]/.test(s))
return "0";
if (s == null || s == "")
return "0";
s = s.toString().replace(/^(\d*)$/, "$1.");
s = (s + "00").replace(/(\d*\.\d\d)\d*/, "$1");
s = s.replace(".", ",");
var re = /(\d)(\d{3},)/;
while (re.test(s))
s = s.replace(re, "$1,$2");
s = s.replace(/,(\d\d)$/, ".$1");
if (type == 0) {
var a = s.split(".");
if (a[1] == "00") {
s = a[0];
}
}
return s;
}
var a = '123,456,789.55';
a = a.replace(/,/g,'');
a = parseFloat(a) + 100;
a = formatMoney(a, 0);
console.log(a);
拥有18年软件开发和IT教学经验。曾任多家上市公司技术总监、架构师、项目经理、高级软件工程师等职务。 网络人气名人讲师,...