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

Side by Side Diff: sdk/lib/core/string.dart

Issue 462463003: Add optional startIndex to String.replaceFirst (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Little fixes Created 6 years, 4 months 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 | « sdk/lib/_internal/lib/string_helper.dart ('k') | tests/corelib/string_replace_test.dart » ('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) 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 391 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 * 402 *
403 * string.contains('X', 1); // false 403 * string.contains('X', 1); // false
404 * string.contains(new RegExp(r'[A-Z]'), 1); // false 404 * string.contains(new RegExp(r'[A-Z]'), 1); // false
405 * 405 *
406 * [startIndex] must not be negative or greater than [length]. 406 * [startIndex] must not be negative or greater than [length].
407 */ 407 */
408 bool contains(Pattern other, [int startIndex = 0]); 408 bool contains(Pattern other, [int startIndex = 0]);
409 409
410 /** 410 /**
411 * Returns a new string in which the first occurence of [from] in this string 411 * Returns a new string in which the first occurence of [from] in this string
412 * is replaced with [to]: 412 * is replaced with [to], starting from [startIndex]:
413 * 413 *
414 * '0.0001'.replaceFirst(new RegExp(r'0'), ''); // '.0001' 414 * '0.0001'.replaceFirst(new RegExp(r'0'), ''); // '.0001'
415 * '0.0001'.replaceFirst(new RegExp(r'0'), '7', 1); // '0.7001'
415 */ 416 */
416 String replaceFirst(Pattern from, String to); 417 String replaceFirst(Pattern from, String to, [int startIndex = 0]);
417 418
418 /** 419 /**
419 * Replaces all substrings that match [from] with [replace]. 420 * Replaces all substrings that match [from] with [replace].
420 * 421 *
421 * Returns a new string in which the non-overlapping substrings matching 422 * Returns a new string in which the non-overlapping substrings matching
422 * [from] (the ones iterated by `from.allMatches(thisString)`) are replaced 423 * [from] (the ones iterated by `from.allMatches(thisString)`) are replaced
423 * by the literal string [replace]. 424 * by the literal string [replace].
424 * 425 *
425 * 'resume'.replaceAll(new RegExp(r'e'), 'é'); // 'résumé' 426 * 'resume'.replaceAll(new RegExp(r'e'), 'é'); // 'résumé'
426 * 427 *
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
735 _position = position - 1; 736 _position = position - 1;
736 _currentCodePoint = _combineSurrogatePair(prevCodeUnit, codeUnit); 737 _currentCodePoint = _combineSurrogatePair(prevCodeUnit, codeUnit);
737 return true; 738 return true;
738 } 739 }
739 } 740 }
740 _position = position; 741 _position = position;
741 _currentCodePoint = codeUnit; 742 _currentCodePoint = codeUnit;
742 return true; 743 return true;
743 } 744 }
744 } 745 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/lib/string_helper.dart ('k') | tests/corelib/string_replace_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698