[Regex] 给数据添加分隔符

2017-01-04  本文已影响0人  oyealex

Regex:##

// 以逗号分隔数据,每三位做一个分隔
(?<=\d)(?<!\.\d*)(?=(?:\d{3})+(?:\.|$))
// replace to  "," 

Analysis:##

Test Case:##

-4321234.12345678
1231238947
13405023405179
+19823748917
+10293490.12341954234
1902378490103.1239412793
-1239478193.1234523452341
123
123456

Result:##

-4,321,234.12345678
1,231,238,947
13,405,023,405,179
+19,823,748,917
+10,293,490.12341954234
1,902,378,490,103.1239412793
-1,239,478,193.1234523452341
123
123,456
上一篇下一篇

猜你喜欢

热点阅读