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

Side by Side Diff: runtime/lib/string.dart

Issue 8379001: Implement String.contains when the pattern is not a string. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 9 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | tests/co19/co19-runtime.status » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 * [StringBase] contains common methods used by concrete String implementations, 6 * [StringBase] contains common methods used by concrete String implementations,
7 * e.g., OneByteString. 7 * e.g., OneByteString.
8 */ 8 */
9 class StringBase { 9 class StringBase {
10 10
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 int last = len - 1; 173 int last = len - 1;
174 for (int i = last; last >= first; last--) { 174 for (int i = last; last >= first; last--) {
175 if (!_isWhitespace(this.charCodeAt(last))) { 175 if (!_isWhitespace(this.charCodeAt(last))) {
176 break; 176 break;
177 } 177 }
178 } 178 }
179 return substringUnchecked_(first, last + 1); 179 return substringUnchecked_(first, last + 1);
180 } 180 }
181 181
182 bool contains(Pattern other, int startIndex) { 182 bool contains(Pattern other, int startIndex) {
183 if (other is RegExp) { 183 if (other is String) {
184 throw "Unimplemented String.contains with RegExp"; 184 return indexOf(other, startIndex) >= 0;
185 } 185 }
186 return indexOf(other, startIndex) >= 0; 186 return other.allMatches(this.substring(startIndex)).iterator().hasNext();
187 } 187 }
188 188
189 String replaceFirst(Pattern from, String to) { 189 String replaceFirst(Pattern from, String to) {
190 if (from is RegExp) { 190 if (from is RegExp) {
191 throw "Unimplemented String.replace with RegExp"; 191 throw "Unimplemented String.replace with RegExp";
192 } 192 }
193 int pos = this.indexOf(from, 0); 193 int pos = this.indexOf(from, 0);
194 if (pos < 0) { 194 if (pos < 0) {
195 return this; 195 return this;
196 } 196 }
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 for (int g in groups) { 435 for (int g in groups) {
436 result.add(group(g)); 436 result.add(group(g));
437 } 437 }
438 return result; 438 return result;
439 } 439 }
440 440
441 final int _start; 441 final int _start;
442 final String str; 442 final String str;
443 final String pattern; 443 final String pattern;
444 } 444 }
OLDNEW
« no previous file with comments | « no previous file | tests/co19/co19-runtime.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698