| 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 * [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 Loading... |
| 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 Loading... |
| 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 } |
| OLD | NEW |