allMatchesWithSep method

List<String> allMatchesWithSep(
  1. String text,
  2. [int start = 0]
)

Given text, get all instances of the text split according to this RegExp.

Implementation

List<String> allMatchesWithSep(String text, [int start = 0]) {
  var result = <String>[];
  for (var match in allMatches(text, start)) {
    result.add(text.substring(start, match.start));
    result.add(match[0] ?? '');
    start = match.end;
  }
  result.add(text.substring(start));
  return result;
}