Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 part of dart.core; | 5 part of dart.core; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * An interface for basic searches within strings. | 8 * An interface for basic searches within strings. |
| 9 */ | 9 */ |
| 10 abstract class Pattern { | 10 abstract class Pattern { |
| 11 // NOTE: When using "start" index from the language library, call | |
| 12 // without an argument if start is zero. This allows backwards compatiblity | |
| 13 // with implementations of the older interface that didn't have the start | |
| 14 // index argument. | |
| 11 /** | 15 /** |
| 12 * Match this pattern against the string repeatedly. | 16 * Match this pattern against the string repeatedly. |
| 13 * | 17 * |
| 18 * If [start] is provided, matching will start at that index. | |
| 19 * | |
| 14 * The iterable will contain all the non-overlapping matches of the | 20 * The iterable will contain all the non-overlapping matches of the |
| 15 * pattern on the string, ordered by start index. | 21 * pattern on the string, ordered by start index. |
| 16 * | 22 * |
| 17 * The matches are found by repeatedly finding the first match | 23 * The matches are found by repeatedly finding the first match |
| 18 * of the pattern on the string, starting from the end of the previous | 24 * of the pattern on the string, starting from the end of the previous |
| 19 * match, and initially starting from index zero. | 25 * match, and initially starting from index zero. |
|
Søren Gjesse
2014/08/19 07:07:59
The phrase "and initially starting from index zero
| |
| 20 * | 26 * |
| 21 * If the pattern matches the empty string at some point, the next | 27 * If the pattern matches the empty string at some point, the next |
| 22 * match is found by starting at the previous match's end plus one. | 28 * match is found by starting at the previous match's end plus one. |
| 23 */ | 29 */ |
| 24 Iterable<Match> allMatches(String str); | 30 Iterable<Match> allMatches(String string, [int start = 0]); |
| 25 | 31 |
| 26 /** | 32 /** |
| 27 * Match this pattern against the start of string. | 33 * Match this pattern against the start of string. |
| 28 * | 34 * |
| 29 * If [start] is provided, it must be an integer in the range `0` .. | 35 * If [start] is provided, it must be an integer in the range `0` .. |
| 30 * `string.length`. In that case, this patten is tested against the | 36 * `string.length`. In that case, this patten is tested against the |
| 31 * string at the [start] position. That is, a match is returned if the | 37 * string at the [start] position. That is, a match is returned if the |
| 32 * pattern can match a part of the string starting from position [start]. | 38 * pattern can match a part of the string starting from position [start]. |
| 33 */ | 39 */ |
| 34 Match matchAsPrefix(String string, [int start = 0]); | 40 Match matchAsPrefix(String string, [int start = 0]); |
| 35 } | 41 } |
| OLD | NEW |