thousands static method
整数增加千位分割符,接收一个整数字符串参数
Implementation
static String thousands(String integerStr) {
if (integerStr.isEmpty) return '0';
RegExp regex = RegExp(r'(\d{1,3})(?=(\d{3})+(?!\d))');
return integerStr.replaceAllMapped(
regex,
(Match match) => '${match.group(1)},',
);
}