mirror of
https://github.com/dart-lang/sdk
synced 2024-11-02 14:32:24 +00:00
Documentation update Pattern
Example codes added. Closes https://github.com/dart-lang/sdk/pull/48005 https://github.com/dart-lang/sdk/pull/48005 GitOrigin-RevId: 7237529636f13def7069c5739376acff67462eb9 Change-Id: Ib41412f9a479b56868644370bf48c61ad3c71b8b Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/225580 Reviewed-by: Lasse Nielsen <lrn@google.com> Commit-Queue: Lasse Nielsen <lrn@google.com>
This commit is contained in:
parent
e3181ae398
commit
9623410e47
1 changed files with 23 additions and 0 deletions
|
@ -20,6 +20,20 @@ abstract class Pattern {
|
|||
/// 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).
|
||||
/// ```dart
|
||||
/// 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
|
||||
/// ```
|
||||
Iterable<Match> allMatches(String string, [int start = 0]);
|
||||
|
||||
/// Matches this pattern against the start of `string`.
|
||||
|
@ -29,6 +43,15 @@ abstract class Pattern {
|
|||
/// at that point.
|
||||
///
|
||||
/// The [start] must be non-negative and no greater than `string.length`.
|
||||
/// ```dart
|
||||
/// final string = 'Dash is a bird';
|
||||
///
|
||||
/// var regExp = RegExp(r'bird');
|
||||
/// var match = regExp.matchAsPrefix(string, 10); // Match found.
|
||||
///
|
||||
/// regExp = RegExp(r'bird');
|
||||
/// match = regExp.matchAsPrefix(string); // null
|
||||
/// ```
|
||||
Match? matchAsPrefix(String string, [int start = 0]);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue