Метод group
- int group
Строка, соответствующая заданной группе.
Если группа равна 0, возвращает весь совпавший фрагмент по шаблону.
Результат может быть null если шаблон не присвоил значение этой группе в рамках данного совпадения.
final string = '[00:13.37] This is a chat message.'; final regExp = RegExp(r'^\[\s*(\d+):(\d+)\.(\d+)\]\s*(.*)$'); final match = regExp.firstMatch(string)!; final message = jsonEncode(match[0]!); // '[00:13.37] This is a chat message.' final hours = jsonEncode(match[1]!); // '00' final minutes = jsonEncode(match[2]!); // '13' final seconds = jsonEncode(match[3]!); // '37' final text = jsonEncode(match[4]!); // 'This is a chat message.'
Реализация
String? group(int group);
© 2012 the Dart project authors
Licensed under the BSD 3-Clause "New" or "Revised" License.
https://api.dart.dev/stable/2.18.5/dart-core/Match/group.html