| 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 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 407 * index: | 407 * index: |
| 408 * | 408 * |
| 409 * string.contains('X', 1); // false | 409 * string.contains('X', 1); // false |
| 410 * string.contains(new RegExp(r'[A-Z]'), 1); // false | 410 * string.contains(new RegExp(r'[A-Z]'), 1); // false |
| 411 * | 411 * |
| 412 * [startIndex] must not be negative or greater than [length]. | 412 * [startIndex] must not be negative or greater than [length]. |
| 413 */ | 413 */ |
| 414 bool contains(Pattern other, [int startIndex = 0]); | 414 bool contains(Pattern other, [int startIndex = 0]); |
| 415 | 415 |
| 416 /** | 416 /** |
| 417 * Returns a new string in which the first occurence of [from] in this string | 417 * Returns a new string in which the first occurence of [from] in this string |
| 418 * is replaced with [to], starting from [startIndex]: | 418 * is replaced with [to], starting from [startIndex]: |
| 419 * | 419 * |
| 420 * '0.0001'.replaceFirst(new RegExp(r'0'), ''); // '.0001' | 420 * '0.0001'.replaceFirst(new RegExp(r'0'), ''); // '.0001' |
| 421 * '0.0001'.replaceFirst(new RegExp(r'0'), '7', 1); // '0.7001' | 421 * '0.0001'.replaceFirst(new RegExp(r'0'), '7', 1); // '0.7001' |
| 422 */ | 422 */ |
| 423 String replaceFirst(Pattern from, String to, [int startIndex = 0]); | 423 String replaceFirst(Pattern from, String to, [int startIndex = 0]); |
| 424 | 424 |
| 425 /** | 425 /** |
| 426 * Replace the first occurence of [from] in this string. | |
| 427 * | |
| 428 * Returns a new string, which is this string | |
| 429 * except that the first match of [pattern], starting from [startIndex], | |
| 430 * is replaced by the result of calling [replace] with the match object. | |
| 431 * | |
| 432 * If the value returned by calling `replace` is not a [String], it | |
| 433 * is converted to a `String` using its `toString` method, which must | |
| 434 * then return a string. | |
| 435 */ | |
| 436 String replaceFirstMapped(Pattern from, String replace(Match match), | |
| 437 [int startIndex = 0]); | |
| 438 | |
| 439 /** | |
| 440 * Replaces all substrings that match [from] with [replace]. | 426 * Replaces all substrings that match [from] with [replace]. |
| 441 * | 427 * |
| 442 * Returns a new string in which the non-overlapping substrings matching | 428 * Returns a new string in which the non-overlapping substrings matching |
| 443 * [from] (the ones iterated by `from.allMatches(thisString)`) are replaced | 429 * [from] (the ones iterated by `from.allMatches(thisString)`) are replaced |
| 444 * by the literal string [replace]. | 430 * by the literal string [replace]. |
| 445 * | 431 * |
| 446 * 'resume'.replaceAll(new RegExp(r'e'), 'é'); // 'résumé' | 432 * 'resume'.replaceAll(new RegExp(r'e'), 'é'); // 'résumé' |
| 447 * | 433 * |
| 448 * Notice that the [replace] string is not interpreted. If the replacement | 434 * Notice that the [replace] string is not interpreted. If the replacement |
| 449 * depends on the match (for example on a [RegExp]'s capture groups), use | 435 * depends on the match (for example on a [RegExp]'s capture groups), use |
| (...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 771 _position = position - 1; | 757 _position = position - 1; |
| 772 _currentCodePoint = _combineSurrogatePair(prevCodeUnit, codeUnit); | 758 _currentCodePoint = _combineSurrogatePair(prevCodeUnit, codeUnit); |
| 773 return true; | 759 return true; |
| 774 } | 760 } |
| 775 } | 761 } |
| 776 _position = position; | 762 _position = position; |
| 777 _currentCodePoint = codeUnit; | 763 _currentCodePoint = codeUnit; |
| 778 return true; | 764 return true; |
| 779 } | 765 } |
| 780 } | 766 } |
| OLD | NEW |