findCapturedGroups method

Map<String, String?> findCapturedGroups(
  1. String source, [
  2. int start = 0
])

Example: expect( FluentRegex() .group(FluentRegex().literal('a').digit().literal('b'), type: GroupType.captureNamed('name')) .findCapturedGroups('@abc2a7bD3e&(f4'), { 'name': 'a7b', });

Implementation

Map<String, String?> findCapturedGroups(String source, [int start = 0]) {
  Map<String, String?> results = {};
  var matches = _toRegExp().allMatches(source, start);
  for (var match in matches) {
    var groupNames = match.groupNames;
    if (groupNames.isEmpty) {
      _appendUnNamedCapturedGroupResults(match, results);
    } else {
      _appendNamedCapturedGroupResults(match, results);
    }
  }
  return results;
}