给金额添加千分位

"123456789" => 123,456,789

'123456789'.replace(/(?=\B(?:\d{3})+$)/g, ',')
'123456789'.replace(/(?=\B(?:\d{3})+$)/g, ',')
'123456789'.replace(/(?=(?!\b)(?:\d{3})+$)/g, ',')
    
 '123456789'.replace(/\B(?=(?:\d{3})+$)/g, ',') 
 '123456789'.replace(/(?!\b)(?=(?:\d{3})+$)/g, ',') 
    
 '123456789'.replace(/(?!^)(?=(?:\d{3})+$)/g, ',')
 '123456789'.replace(/(?=(?!^)(?:\d{3})+$)/g, ',')

 

"123456789 123456789 " => 123,456,789 123,456,789

'123456789 123456789 '.replace(/(?=\B(?:\d{3})+\b)/g, ',')
'123456789 123456789 '.replace(/(?=(?!\b)(?:\d{3})+\b)/g, ',')
    
'123456789 123456789 '.replace(/\B(?=(?:\d{3})+\b)/g, ',') 
'123456789 123456789 '.replace(/(?!\b)(?=(?:\d{3})+\b)/g, ',') 

 

1888 => $ 1888.00

188..toFixed(2).replace(/(?!^)(?=(?:\d{3})+\b)/g, ',').replace(/^/, "$")

 

上一篇:Linux系统 ifconfig使用不了


下一篇:centos最小化安装后ifconfig提示未找到该命令