Best way to get all substrings matching a RegExp in Dart Best way to get all substrings matching a RegExp in Dart dart dart

Best way to get all substrings matching a RegExp in Dart


If your regexp contains only one group (like new RegExp(r'(\S+)')) you can rewrite your function to:

Iterable<String> _allStringMatches(String text, RegExp regExp) =>     regExp.allMatches(text).map((m) => m.group(0));