千份位Javascript Thousand Separator / string format

zyip發表於2016-07-04

 

function Separator(str){
return str.split(/(\d+)(\d{3})(\d{3})(\d{3})(\d{3})/).join(',').replace(/^,?/,'').replace(',.','.');
}

  

https://github.com/zyip/Numeral-js/blob/master/numeral.js

 https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toLocaleString

 

相關文章