标签:string 分隔符 replace $0 log pre color console return
function commafy(num) { return num && num .toString() .replace(/(\d)(?=(\d{3})+\.)/g, function($0, $1) { return $1 + ","; }); } console.log(commafy(1234567.90)); //1,234,567.90
标签:string 分隔符 replace $0 log pre color console return
原文地址:http://www.cnblogs.com/samsara-yx/p/7904407.html