Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: test/generated_sdk/lib/core/regexp.dart

Issue 1162723007: remove generated_sdk from checked in code (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « test/generated_sdk/lib/core/print.dart ('k') | test/generated_sdk/lib/core/set.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 part of dart.core;
6
7 /**
8 * A result from searching within a string.
9 *
10 * A Match or an [Iterable] of Match objects is returned from [Pattern]
11 * matching methods.
12 *
13 * The following example finds all matches of a [RegExp] in a [String]
14 * and iterates through the returned iterable of Match objects.
15 *
16 * RegExp exp = new RegExp(r"(\w+)");
17 * String str = "Parse my string";
18 * Iterable<Match> matches = exp.allMatches(str);
19 * for (Match m in matches) {
20 * String match = m.group(0);
21 * print(match);
22 * }
23 *
24 * The output of the example is:
25 *
26 * Parse
27 * my
28 * string
29 *
30 * Some patterns, regular expressions in particular, may record subtrings
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
33 * have zero [groupCount].
34 */
35 abstract class Match {
36 /**
37 * Returns the index in the string where the match starts.
38 */
39 int get start;
40
41 /**
42 * Returns the index in the string after the last character of the
43 * match.
44 */
45 int get end;
46
47 /**
48 * Returns the string matched by the given [group].
49 *
50 * If [group] is 0, returns the match of the pattern.
51 *
52 * The result may be `null` if the pattern didn't assign a value to it
53 * as part of this match.
54 */
55 String group(int group);
56
57 /**
58 * Returns the string matched by the given [group].
59 *
60 * If [group] is 0, returns the match of the pattern.
61 *
62 * Short alias for [Match.group].
63 */
64 String operator [](int group);
65
66 /**
67 * Returns a list of the groups with the given indices.
68 *
69 * The list contains the strings returned by [group] for each index in
70 * [groupIndices].
71 */
72 List<String> groups(List<int> groupIndices);
73
74 /**
75 * Returns the number of captured groups in the match.
76 *
77 * Some patterns may capture parts of the input that was used to
78 * compute the full match. This is the number of captured groups,
79 * which is also the maximal allowed argument to the [group] method.
80 */
81 int get groupCount;
82
83 /**
84 * The string on which this match was computed.
85 */
86 String get input;
87
88 /**
89 * The pattern used to search in [input].
90 */
91 Pattern get pattern;
92 }
93
94
95 /**
96 * A regular expression pattern.
97 *
98 * Regular expressions are [Pattern]s, and can as such be used to match strings
99 * or parts of strings.
100 *
101 * Dart regular expressions have the same syntax and semantics as
102 * JavaScript regular expressions. See
103 * <http://ecma-international.org/ecma-262/5.1/#sec-15.10>
104 * for the specification of JavaScript regular expressions.
105 *
106 * [firstMatch] is the main implementation method that applies a regular
107 * expression to a string and returns the first [Match]. All
108 * other methods in [RegExp] can build on it.
109 *
110 * Use [allMatches] to look for all matches of a regular expression in
111 * a string.
112 *
113 * The following example finds all matches of a regular expression in
114 * a string.
115 *
116 * RegExp exp = new RegExp(r"(\w+)");
117 * String str = "Parse my string";
118 * Iterable<Match> matches = exp.allMatches(str);
119 */
120 abstract class RegExp implements Pattern {
121 /**
122 * Constructs a regular expression.
123 *
124 * Throws a [FormatException] if [source] is not valid regular
125 * expression syntax.
126 */
127 factory RegExp(String source,
128 {bool multiLine: false,
129 bool caseSensitive: true})
130 => new JSSyntaxRegExp(source,
131 multiLine: multiLine,
132 caseSensitive: caseSensitive);
133
134 /**
135 * Searches for the first match of the regular expression
136 * in the string [input]. Returns `null` if there is no match.
137 */
138 Match firstMatch(String input);
139
140 /**
141 * Returns an iterable of the matches of the regular expression on [input].
142 *
143 * If [start] is provided, only start looking for matches at `start`.
144 */
145 Iterable<Match> allMatches(String input, [int start = 0]);
146
147 /**
148 * Returns whether the regular expression has a match in the string [input].
149 */
150 bool hasMatch(String input);
151
152 /**
153 * Returns the first substring match of this regular expression in [input].
154 */
155 String stringMatch(String input);
156
157 /**
158 * The source regular expression string used to create this `RegExp`.
159 */
160 String get pattern;
161
162 /**
163 * Whether this regular expression matches multiple lines.
164 *
165 * If the regexp does match multiple lines, the "^" and "$" characters
166 * match the beginning and end of lines. If not, the character match the
167 * beginning and end of the input.
168 */
169 bool get isMultiLine;
170
171 /**
172 * Whether this regular expression is case sensitive.
173 *
174 * If the regular expression is not case sensitive, it will match an input
175 * letter with a pattern letter even if the two letters are different case
176 * versions of the same letter.
177 */
178 bool get isCaseSensitive;
179 }
OLDNEW
« no previous file with comments | « test/generated_sdk/lib/core/print.dart ('k') | test/generated_sdk/lib/core/set.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698