Movatterモバイル変換


[0]ホーム

URL:


menu
  1. Dart
  2. dart:core
  3. Match class
Match
description

Match classabstractinterface

A result from searching within a string.

AMatch or anIterable ofMatch objects is returned fromthePattern matching methods(Pattern.allMatches andPattern.matchAsPrefix).

The following example finds all matches of aRegExp in aStringand iterates through the returned iterable ofMatch objects.

final regExp = RegExp(r'(\w+)');const string = 'Parse my string';final matches = regExp.allMatches(string);for (final m in matches) {  String match = m[0]!;  print(match);}

The output of the example is:

Parsemystring

Some patterns, regular expressions in particular, may record substringsthat were part of the matching. These are calledgroups in theMatchobject. Some patterns may never have any groups, and their matches alwayshave zerogroupCount.

Implementers

Properties

endint
The index in the string after the last character of the match.
no setter
groupCountint
Returns the number of captured groups in the match.
no setter
hashCodeint
The hash code for this object.
no setterinherited
inputString
The string on which this match was computed.
no setter
patternPattern
The pattern used to search ininput.
no setter
runtimeTypeType
A representation of the runtime type of the object.
no setterinherited
startint
The index in the string where the match starts.
no setter

Methods

group(intgroup)String?
The string matched by the givengroup.
groups(List<int>groupIndices)List<String?>
A list of the groups with the given indices.
noSuchMethod(Invocationinvocation)→ dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString()String
A string representation of this object.
inherited

Operators

operator ==(Objectother)bool
The equality operator.
inherited
operator [](intgroup)String?
The string matched by the givengroup.
  1. Dart
  2. dart:core
  3. Match class
dart:core library

[8]ページ先頭

©2009-2025 Movatter.jp