allMatches method
Matches this pattern against the string repeatedly.
If start
is provided, matching will start at that index.
The returned iterable lazily finds non-overlapping matches
of the pattern in the string
.
If a user only requests the first match,
this function should not compute all possible matches.
The matches are found by repeatedly finding the first match
of the pattern in the string, initially starting from start
,
and then from the end of the previous match (but always
at least one position later than the start of the previous
match, in case the pattern matches an empty substring).
RegExp exp = RegExp(r'(\w+)');
var str = 'Dash is a bird';
Iterable<Match> matches = exp.allMatches(str, 8);
for (final Match m in matches) {
String match = m[0]!;
print(match);
}
The output of the example is:
a
bird
Implementation
@override
Iterable<Match> allMatches(String str, [int start = 0]) =>
regex.allMatches(str, start);