function thousandBitSeparator(num){
      var re=/\d{1,3}(?=(\d{3})+$)/g;
      var n1=num.toString().replace(/^(\d+)((\.\d+)?)$/,function(s,s1,s2){return s1.replace(re,"$&,")+s2;});
      return n1;
    }

 

posted on 2018-05-11 18:22  程序员丁先生  阅读(277)  评论(0编辑  收藏  举报