1 var getThousandNum = function(val){ 2 var re = /(?=(?!(\b))(\d{3})+$)/g; 3 return val.indexOf(".")>=0 ? val.split(".")[0].replace(re, ",") + "." +val.split(".")[1] : val.replace(re, ","); 4 }