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

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

Issue 190853009: Add string.trimLeft/trimRight. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Remove left-over debugging aid. Created 6 years, 9 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/js_string.dart ('k') | tests/corelib/corelib.status » ('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 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 * Returns the substring of this string that extends from [startIndex], 283 * Returns the substring of this string that extends from [startIndex],
284 * inclusive, to [endIndex], exclusive. 284 * inclusive, to [endIndex], exclusive.
285 * 285 *
286 * var string = 'dartlang'; 286 * var string = 'dartlang';
287 * string.substring(1); // 'artlang' 287 * string.substring(1); // 'artlang'
288 * string.substring(1, 4); // 'art' 288 * string.substring(1, 4); // 'art'
289 */ 289 */
290 String substring(int startIndex, [int endIndex]); 290 String substring(int startIndex, [int endIndex]);
291 291
292 /** 292 /**
293 * Removes leading and trailing whitespace from a string. 293 * Returns the string without any leading and trailing whitespace.
294 * 294 *
295 * If the string contains leading or trailing whitespace, a new string with no 295 * If the string contains leading or trailing whitespace, a new string with no
296 * leading and no trailing whitespace is returned: 296 * leading and no trailing whitespace is returned:
297 * 297 *
298 * '\tDart is fun\n'.trim(); // 'Dart is fun' 298 * '\tDart is fun\n'.trim(); // 'Dart is fun'
299 * 299 *
300 * Otherwise, the original string itself is returned: 300 * Otherwise, the original string itself is returned:
301 * 301 *
302 * var str1 = 'Dart'; 302 * var str1 = 'Dart';
303 * var str2 = str1.trim(); 303 * var str2 = str1.trim();
(...skipping 15 matching lines...) Expand all
319 * 2029 ; White_Space # Zp PARAGRAPH SEPARATOR 319 * 2029 ; White_Space # Zp PARAGRAPH SEPARATOR
320 * 202F ; White_Space # Zs NARROW NO-BREAK SPACE 320 * 202F ; White_Space # Zs NARROW NO-BREAK SPACE
321 * 205F ; White_Space # Zs MEDIUM MATHEMATICAL SPACE 321 * 205F ; White_Space # Zs MEDIUM MATHEMATICAL SPACE
322 * 3000 ; White_Space # Zs IDEOGRAPHIC SPACE 322 * 3000 ; White_Space # Zs IDEOGRAPHIC SPACE
323 * 323 *
324 * FEFF ; BOM ZERO WIDTH NO_BREAK SPACE 324 * FEFF ; BOM ZERO WIDTH NO_BREAK SPACE
325 */ 325 */
326 String trim(); 326 String trim();
327 327
328 /** 328 /**
329 * Returns the string without any leading whitespace.
330 *
331 * As [trim], but only removes leading whitespace.
332 */
333 String trimLeft();
334
335 /**
336 * Returns the string without any trailing whitespace.
337 *
338 * As [trim], but only removes trailing whitespace.
339 */
340 String trimRight();
341
342 /**
329 * Creates a new string by concatenating this string with itself a number 343 * Creates a new string by concatenating this string with itself a number
330 * of times. 344 * of times.
331 * 345 *
332 * The result of `str * n` is equivalent to 346 * The result of `str * n` is equivalent to
333 * `str + str + ...`(n times)`... + str`. 347 * `str + str + ...`(n times)`... + str`.
334 * 348 *
335 * Returns an empty string if [times] is zero or negative. 349 * Returns an empty string if [times] is zero or negative.
336 */ 350 */
337 String operator *(int times); 351 String operator *(int times);
338 352
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
717 _position = position - 1; 731 _position = position - 1;
718 _currentCodePoint = _combineSurrogatePair(prevCodeUnit, codeUnit); 732 _currentCodePoint = _combineSurrogatePair(prevCodeUnit, codeUnit);
719 return true; 733 return true;
720 } 734 }
721 } 735 }
722 _position = position; 736 _position = position;
723 _currentCodePoint = codeUnit; 737 _currentCodePoint = codeUnit;
724 return true; 738 return true;
725 } 739 }
726 } 740 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/lib/js_string.dart ('k') | tests/corelib/corelib.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698