Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR DART

flutter string add , for 1000

RegExp reg = RegExp(r'(d{1,3})(?=(d{3})+(?!d))');
String Function(Match) mathFunc = (Match match) => '${match[1]},';

List<String> tests = [
  '0',
  '10',
  '123',
  '1230',
  '12300',
  '123040',
  '12k',
  '12 ',
];

for (String test in tests) {    
  String result = test.replaceAllMapped(reg, mathFunc);
  print('$test -> $result');
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #flutter #string #add
ADD COMMENT
Topic
Name
6+1 =