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 /** | 5 /** |
6 * [Match] contains methods to manipulate a regular expression match. | 6 * [Match] contains methods to manipulate a regular expression match. |
7 * | 7 * |
8 * Iterables of [Match] objects are returned from [RegExp] matching methods. | 8 * Iterables of [Match] objects are returned from [RegExp] matching methods. |
9 * | 9 * |
10 * The following example finds all matches of a [RegExp] in a [String] | 10 * The following example finds all matches of a [RegExp] in a [String] |
11 * and iterates through the returned iterable of [Match] objects. | 11 * and iterates through the returned iterable of [Match] objects. |
12 * | 12 * |
13 * [: | 13 * [: |
14 * RegExp exp = const RegExp(@"(\w+)"); | 14 * RegExp exp = const RegExp(@"(\w+)"); |
15 * String str = "Parse my string"; | 15 * String str = "Parse my string"; |
16 * Iterable<Match> matches = exp.allMatches(str, exp); | 16 * Iterable<Match> matches = exp.allMatches(str); |
17 * for (Match m in matches) { | 17 * for (Match m in matches) { |
18 * String match = m.group(0); | 18 * String match = m.group(0); |
19 * print(match); | 19 * print(match); |
20 * }; | 20 * }; |
21 * :] | 21 * :] |
22 * | 22 * |
23 * The output of the example is: | 23 * The output of the example is: |
24 * | 24 * |
25 * [: | 25 * [: |
26 * Parse | 26 * Parse |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 * | 79 * |
80 * Use [allMatches] to look for all matches of a regular expression in | 80 * Use [allMatches] to look for all matches of a regular expression in |
81 * a string. | 81 * a string. |
82 * | 82 * |
83 * The following example finds all matches of a regular expression in | 83 * The following example finds all matches of a regular expression in |
84 * a string. | 84 * a string. |
85 * | 85 * |
86 * [: | 86 * [: |
87 * RegExp exp = const RegExp(@"(\w+)"); | 87 * RegExp exp = const RegExp(@"(\w+)"); |
88 * String str = "Parse my string"; | 88 * String str = "Parse my string"; |
89 * Iterable<Match> matches = exp.allMatches(str, exp); | 89 * Iterable<Match> matches = exp.allMatches(str); |
90 * :] | 90 * :] |
91 */ | 91 */ |
92 interface RegExp extends Pattern factory JSSyntaxRegExp { | 92 interface RegExp extends Pattern factory JSSyntaxRegExp { |
93 | 93 |
94 /** | 94 /** |
95 * Constructs a regular expression. The default implementation of a | 95 * Constructs a regular expression. The default implementation of a |
96 * [RegExp] sets [multiLine] and [ignoreCase] to false. | 96 * [RegExp] sets [multiLine] and [ignoreCase] to false. |
97 */ | 97 */ |
98 const RegExp(String pattern, [bool multiLine, bool ignoreCase]); | 98 const RegExp(String pattern, [bool multiLine, bool ignoreCase]); |
99 | 99 |
(...skipping 28 matching lines...) Expand all Loading... |
128 /** | 128 /** |
129 * Whether this regular expression matches multiple lines. | 129 * Whether this regular expression matches multiple lines. |
130 */ | 130 */ |
131 final bool multiLine; | 131 final bool multiLine; |
132 | 132 |
133 /** | 133 /** |
134 * Whether this regular expression is case insensitive. | 134 * Whether this regular expression is case insensitive. |
135 */ | 135 */ |
136 final bool ignoreCase; | 136 final bool ignoreCase; |
137 } | 137 } |
OLD | NEW |