Dart how to add commas to a string number

前端 未结 2 1395
一整个雨季
一整个雨季 2021-02-13 02:54

I\'m trying to adapt this: Insert commas into number string to work in dart, but no luck.

either one of these don\'t work:

print(\"1000200\".replaceAllMa         


        
2条回答
  •  孤城傲影
    2021-02-13 03:33

    Try the following regex: (\d{1,3})(?=(\d{3})+$)

    This will provide two backreferences, and replacing your number using them like $1,$2, will add commas where they are supposed to be.

提交回复
热议问题