| 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 } | 173 } |
| 174 int last = len - 1; | 174 int last = len - 1; |
| 175 for (int i = last; last >= first; last--) { | 175 for (int i = last; last >= first; last--) { |
| 176 if (!_isWhitespace(this.charCodeAt(last))) { | 176 if (!_isWhitespace(this.charCodeAt(last))) { |
| 177 break; | 177 break; |
| 178 } | 178 } |
| 179 } | 179 } |
| 180 return substringUnchecked_(first, last + 1); | 180 return substringUnchecked_(first, last + 1); |
| 181 } | 181 } |
| 182 | 182 |
| 183 bool contains(Pattern other, int startIndex) { | 183 bool contains(Pattern other, [int startIndex = 0]) { |
| 184 if (other is String) { | 184 if (other is String) { |
| 185 return indexOf(other, startIndex) >= 0; | 185 return indexOf(other, startIndex) >= 0; |
| 186 } | 186 } |
| 187 return other.allMatches(this.substring(startIndex)).iterator().hasNext(); | 187 return other.allMatches(this.substring(startIndex)).iterator().hasNext(); |
| 188 } | 188 } |
| 189 | 189 |
| 190 String replaceFirst(Pattern from, String to) { | 190 String replaceFirst(Pattern from, String to) { |
| 191 if (from is RegExp) { | 191 if (from is RegExp) { |
| 192 throw "Unimplemented String.replace with RegExp"; | 192 throw "Unimplemented String.replace with RegExp"; |
| 193 } | 193 } |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 436 for (int g in groups) { | 436 for (int g in groups) { |
| 437 result.add(group(g)); | 437 result.add(group(g)); |
| 438 } | 438 } |
| 439 return result; | 439 return result; |
| 440 } | 440 } |
| 441 | 441 |
| 442 final int _start; | 442 final int _start; |
| 443 final String str; | 443 final String str; |
| 444 final String pattern; | 444 final String pattern; |
| 445 } | 445 } |
| OLD | NEW |