Dart how to add commas to a string number

前端 未结 2 1249
执念已碎
执念已碎 2021-02-13 03:23

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:41

    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.

提交回复
热议问题