private static List<RegExpMatch> collectMatches(Matcher matcher) {
    List<RegExpMatch> matches = new SmartList<>();
    do {
      final RegExpMatch match = new RegExpMatch();
      final int count = matcher.groupCount();
      for (int i = 0; i <= count; i++) {
        match.add(matcher.start(i), matcher.end(i));
      }
      matches.add(match);
    }
    while (matcher.find());
    return matches;
  }
private static List<RegExpMatch> collectMatches(Matcher matcher)