Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 * [Match] contains methods to manipulate a pattern match. | 8 * A result from searching within a string. |
| 9 * | 9 * |
| 10 * A [Match] or and iterable of [Match] objects are returned from [Pattern] | 10 * A Match or an [Iterable] of Match objects is returned from [Pattern] |
|
Lasse Reichstein Nielsen
2016/08/31 18:57:36
`Match` *2
| |
| 11 * matching methods. | 11 * matching methods. |
| 12 * | 12 * |
| 13 * The following example finds all matches of a [RegExp] in a [String] | 13 * The following example finds all matches of a [RegExp] in a [String] |
| 14 * and iterates through the returned iterable of [Match] objects. | 14 * and iterates through the returned iterable of Match objects. |
| 15 * | 15 * |
| 16 * RegExp exp = new RegExp(r"(\w+)"); | 16 * RegExp exp = new RegExp(r"(\w+)"); |
| 17 * String str = "Parse my string"; | 17 * String str = "Parse my string"; |
| 18 * Iterable<Match> matches = exp.allMatches(str); | 18 * Iterable<Match> matches = exp.allMatches(str); |
| 19 * for (Match m in matches) { | 19 * for (Match m in matches) { |
| 20 * String match = m.group(0); | 20 * String match = m.group(0); |
| 21 * print(match); | 21 * print(match); |
| 22 * } | 22 * } |
| 23 * | 23 * |
| 24 * The output of the example is: | 24 * The output of the example is: |
| 25 * | 25 * |
| 26 * Parse | 26 * Parse |
| 27 * my | 27 * my |
| 28 * string | 28 * string |
| 29 * | 29 * |
| 30 * Some patterns, regular expressions in particular, may record subtrings | 30 * Some patterns, regular expressions in particular, may record subtrings |
| 31 * that were part of the matching. These are called "groups" in the `Match` | 31 * that were part of the matching. These are called _groups_ in the Match |
| 32 * object. Some patterns may never have any groups, and their matches always | 32 * object. Some patterns may never have any groups, and their matches always |
| 33 * have zero [groupCount]. | 33 * have zero [groupCount]. |
| 34 */ | 34 */ |
| 35 abstract class Match { | 35 abstract class Match { |
| 36 /** | 36 /** |
| 37 * Returns the index in the string where the match starts. | 37 * Returns the index in the string where the match starts. |
| 38 */ | 38 */ |
| 39 int get start; | 39 int get start; |
| 40 | 40 |
| 41 /** | 41 /** |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 172 | 172 |
| 173 /** | 173 /** |
| 174 * Whether this regular expression is case sensitive. | 174 * Whether this regular expression is case sensitive. |
| 175 * | 175 * |
| 176 * If the regular expression is not case sensitive, it will match an input | 176 * If the regular expression is not case sensitive, it will match an input |
| 177 * letter with a pattern letter even if the two letters are different case | 177 * letter with a pattern letter even if the two letters are different case |
| 178 * versions of the same letter. | 178 * versions of the same letter. |
| 179 */ | 179 */ |
| 180 bool get isCaseSensitive; | 180 bool get isCaseSensitive; |
| 181 } | 181 } |
| OLD | NEW |