var numberFormat = function(num){ return num.toString().replace(/^\d+[^\.]/, function(t){return t.replace(/([\d]+?)(?=(?:\d{3})+$)/g, function(t){ return t + ','; });}); }
小数点対応
参考:http://d.hatena.ne.jp/mtoyoshi/20090321/1237723345
var numberFormat = function(num){ return num.toString().replace(/^\d+[^\.]/, function(t){return t.replace(/([\d]+?)(?=(?:\d{3})+$)/g, function(t){ return t + ','; });}); }
小数点対応
参考:http://d.hatena.ne.jp/mtoyoshi/20090321/1237723345