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 | 11 // NOTE: When using "start" index from the language library, call |
12 // without an argument if start is zero. This allows backwards compatiblity | 12 // without an argument if start is zero. This allows backwards compatibility |
13 // with implementations of the older interface that didn't have the start | 13 // with implementations of the older interface that didn't have the start |
14 // index argument. | 14 // index argument. |
15 /** | 15 /** |
16 * Match this pattern against the string repeatedly. | 16 * Match this pattern against the string repeatedly. |
17 * | 17 * |
18 * If [start] is provided, matching will start at that index. | 18 * If [start] is provided, matching will start at that index. |
19 * | 19 * |
20 * The returned iterable lazily computes all the non-overlapping matches | 20 * The returned iterable lazily computes all the non-overlapping matches |
21 * of the pattern on the string, ordered by start index. | 21 * of the pattern on the string, ordered by start index. |
22 * If a user only requests the first | 22 * If a user only requests the first |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 * String match = m.group(0); | 59 * String match = m.group(0); |
60 * print(match); | 60 * print(match); |
61 * } | 61 * } |
62 * | 62 * |
63 * The output of the example is: | 63 * The output of the example is: |
64 * | 64 * |
65 * Parse | 65 * Parse |
66 * my | 66 * my |
67 * string | 67 * string |
68 * | 68 * |
69 * Some patterns, regular expressions in particular, may record subtrings | 69 * Some patterns, regular expressions in particular, may record substrings |
70 * that were part of the matching. These are called _groups_ in the Match | 70 * that were part of the matching. These are called _groups_ in the Match |
71 * object. Some patterns may never have any groups, and their matches always | 71 * object. Some patterns may never have any groups, and their matches always |
72 * have zero [groupCount]. | 72 * have zero [groupCount]. |
73 */ | 73 */ |
74 abstract class Match { | 74 abstract class Match { |
75 /** | 75 /** |
76 * Returns the index in the string where the match starts. | 76 * Returns the index in the string where the match starts. |
77 */ | 77 */ |
78 int get start; | 78 int get start; |
79 | 79 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 /** | 122 /** |
123 * The string on which this match was computed. | 123 * The string on which this match was computed. |
124 */ | 124 */ |
125 String get input; | 125 String get input; |
126 | 126 |
127 /** | 127 /** |
128 * The pattern used to search in [input]. | 128 * The pattern used to search in [input]. |
129 */ | 129 */ |
130 Pattern get pattern; | 130 Pattern get pattern; |
131 } | 131 } |
OLD | NEW |