| 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 * A sequence of characters. | 8 * A sequence of characters. |
| 9 * | 9 * |
| 10 * A string can be either single or multiline. Single line strings are | 10 * A string can be either single or multiline. Single line strings are |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 * starting at [start], inclusive: | 250 * starting at [start], inclusive: |
| 251 * | 251 * |
| 252 * var string = 'Dartisans'; | 252 * var string = 'Dartisans'; |
| 253 * string.indexOf('art'); // 1 | 253 * string.indexOf('art'); // 1 |
| 254 * string.indexOf(new RegExp(r'[A-Z][a-z]')); // 0 | 254 * string.indexOf(new RegExp(r'[A-Z][a-z]')); // 0 |
| 255 * | 255 * |
| 256 * Returns -1 if no match is found: | 256 * Returns -1 if no match is found: |
| 257 * | 257 * |
| 258 * string.indexOf(new RegExp(r'dart')); // -1 | 258 * string.indexOf(new RegExp(r'dart')); // -1 |
| 259 * | 259 * |
| 260 * [start] must not be negative or greater than [length]. | 260 * [start] must be non-negative and not greater than [length]. |
| 261 */ | 261 */ |
| 262 int indexOf(Pattern pattern, [int start]); | 262 int indexOf(Pattern pattern, [int start]); |
| 263 | 263 |
| 264 /** | 264 /** |
| 265 * Returns the position of the last match [pattern] in this string, searching | 265 * Returns the position of the last match [pattern] in this string, searching |
| 266 * backward starting at [start], inclusive: | 266 * backward starting at [start], inclusive: |
| 267 * | 267 * |
| 268 * var string = 'Dartisans'; | 268 * var string = 'Dartisans'; |
| 269 * string.lastIndexOf('a'); // 6 | 269 * string.lastIndexOf('a'); // 6 |
| 270 * string.lastIndexOf(new RegExp(r'a(r|n)')); // 6 | 270 * string.lastIndexOf(new RegExp(r'a(r|n)')); // 6 |
| 271 * | 271 * |
| 272 * Returns -1 if [other] could not be found. | 272 * Returns -1 if [pattern] could not be found in this string. |
| 273 * | 273 * |
| 274 * string.lastIndexOf(new RegExp(r'DART')); // -1 | 274 * string.lastIndexOf(new RegExp(r'DART')); // -1 |
| 275 * | 275 * |
| 276 * [start] must not be negative or greater than [length]. | 276 * The [start] must be non-negative and not greater than [length]. |
| 277 */ | 277 */ |
| 278 int lastIndexOf(Pattern pattern, [int start]); | 278 int lastIndexOf(Pattern pattern, [int start]); |
| 279 | 279 |
| 280 /** | 280 /** |
| 281 * Returns true if this string is empty. | 281 * Returns true if this string is empty. |
| 282 */ | 282 */ |
| 283 bool get isEmpty; | 283 bool get isEmpty; |
| 284 | 284 |
| 285 /** | 285 /** |
| 286 * Returns true if this string is not empty. | 286 * Returns true if this string is not empty. |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 424 * | 424 * |
| 425 * '0.0001'.replaceFirst(new RegExp(r'0'), ''); // '.0001' | 425 * '0.0001'.replaceFirst(new RegExp(r'0'), ''); // '.0001' |
| 426 * '0.0001'.replaceFirst(new RegExp(r'0'), '7', 1); // '0.7001' | 426 * '0.0001'.replaceFirst(new RegExp(r'0'), '7', 1); // '0.7001' |
| 427 */ | 427 */ |
| 428 String replaceFirst(Pattern from, String to, [int startIndex = 0]); | 428 String replaceFirst(Pattern from, String to, [int startIndex = 0]); |
| 429 | 429 |
| 430 /** | 430 /** |
| 431 * Replace the first occurrence of [from] in this string. | 431 * Replace the first occurrence of [from] in this string. |
| 432 * | 432 * |
| 433 * Returns a new string, which is this string | 433 * Returns a new string, which is this string |
| 434 * except that the first match of [pattern], starting from [startIndex], | 434 * except that the first match of [from], starting from [startIndex], |
| 435 * is replaced by the result of calling [replace] with the match object. | 435 * is replaced by the result of calling [replace] with the match object. |
| 436 * | 436 * |
| 437 * The optional [startIndex] is by default set to 0. If provided, it must be | 437 * The optional [startIndex] is by default set to 0. If provided, it must be |
| 438 * an integer in the range `[0 .. len]`, where `len` is this string's length. | 438 * an integer in the range `[0 .. len]`, where `len` is this string's length. |
| 439 * | 439 * |
| 440 * If the value returned by calling `replace` is not a [String], it | 440 * If the value returned by calling `replace` is not a [String], it |
| 441 * is converted to a `String` using its `toString` method, which must | 441 * is converted to a `String` using its `toString` method, which must |
| 442 * then return a string. | 442 * then return a string. |
| 443 */ | 443 */ |
| 444 String replaceFirstMapped(Pattern from, String replace(Match match), | 444 String replaceFirstMapped(Pattern from, String replace(Match match), |
| (...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 795 _position = position - 1; | 795 _position = position - 1; |
| 796 _currentCodePoint = _combineSurrogatePair(prevCodeUnit, codeUnit); | 796 _currentCodePoint = _combineSurrogatePair(prevCodeUnit, codeUnit); |
| 797 return true; | 797 return true; |
| 798 } | 798 } |
| 799 } | 799 } |
| 800 _position = position; | 800 _position = position; |
| 801 _currentCodePoint = codeUnit; | 801 _currentCodePoint = codeUnit; |
| 802 return true; | 802 return true; |
| 803 } | 803 } |
| 804 } | 804 } |
| OLD | NEW |