description

# RegExpMatch class abstract interface

A regular expression match.

Regular expression matches are Matches. They also include the ability to retrieve the names for any named capture groups and to retrieve matches for named capture groups by name instead of by their index.

Example:

    const pattern =
        r'^\[(?<Time>\s*((?<hour>\d+)):((?<minute>\d+))\.((?<second>\d+)))\]'
        r'\s(?<Message>\s*(.*)$)';

    final regExp = RegExp(
      pattern,
      multiLine: true,
    );

    const multilineText = '[00:13.37] This is a first message.\n'
        '[01:15.57] This is a second message.\n';

    RegExpMatch regExpMatch = regExp.firstMatch(multilineText)!;
    print(regExpMatch.groupNames.join('-')); // hour-minute-second-Time-Message.
    final time = regExpMatch.namedGroup('Time'); // 00:13.37
    final hour = regExpMatch.namedGroup('hour'); // 00
    final minute = regExpMatch.namedGroup('minute'); // 13
    final second = regExpMatch.namedGroup('second'); // 37
    final message =
        regExpMatch.namedGroup('Message'); // This is the first message.
    final date = regExpMatch.namedGroup('Date'); // Undefined `Date`, throws.

    Iterable<RegExpMatch> matches = regExp.allMatches(multilineText);
    for (final m in matches) {
      print(m.namedGroup('Time'));
      print(m.namedGroup('Message'));
      // 00:13.37
      // This is the first message.
      // 01:15.57
      // This is the second message.
    }

Implemented types
  - Match
Annotations
  - @Deprecated.implement("This class will become 'final' in a future release." "'Match' may be a more appropriate interface to implement.")

## Properties

end → int
  The index in the string after the last character of the match.
  no setterinherited
groupCount → int
  Returns the number of captured groups in the match.
  no setterinherited
groupNames → Iterable<String>
  The names of the named capture groups of pattern.
  no setter
hashCode → int
  The hash code for this object.
  no setterinherited
input → String
  The string on which this match was computed.
  no setterinherited
pattern → RegExp
  The pattern used to search in input.
  no setteroverride
runtimeType → Type
  A representation of the runtime type of the object.
  no setterinherited
start → int
  The index in the string where the match starts.
  no setterinherited

## Methods

group(int group) → String?
  The string matched by the given `group`.
  inherited
groups(List<int> groupIndices) → List<String?>
  A list of the groups with the given indices.
  inherited
namedGroup(String name) → String?
  The string captured by the named capture group `name`.
noSuchMethod(Invocation invocation) → dynamic
  Invoked when a nonexistent method or property is accessed.
  inherited
toString() → String
  A string representation of this object.
  inherited

## Operators

operator ==(Object other) → bool
  The equality operator.
  inherited
operator [](int group) → String?
  The string matched by the given `group`.
  inherited