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 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 * Creates a new string that repeats this string a number of times. | 329 * Creates a new string by concatenating this string with itself a number |
| 330 * of times. |
330 * | 331 * |
331 * If [separator] is provided, it is inserted between the copies | 332 * The result of `str * n` is equivalent to |
332 * of this string. | 333 * `str + str + ...`(n times)`... + str`. |
333 * | 334 * |
334 * The [times] number must be non-negative. | 335 * Returns an empty string if [times] is zero or negative. |
335 */ | 336 */ |
336 String repeat(int times, [String separator = ""]); | 337 String operator *(int times); |
337 | 338 |
338 /** | 339 /** |
339 * Pads this string on the left if it is shorther than [newSize]. | 340 * Pads this string on the left if it is shorther than [width]. |
340 * | 341 * |
341 * Return a new string that prepends [padding] onto this string | 342 * Return a new string that prepends [padding] onto this string |
342 * until the total length is [newLength]. | 343 * one time for each position the length is less than [width]. |
343 * | 344 * |
344 * If [newLength] is already smaller than or equal to `this.length`, | 345 * If [width] is already smaller than or equal to `this.length`, |
345 * no padding will happen. A negative `newLength` is allowed, | 346 * no padding is added. A negative `width` is treated as zero. |
346 * but no padding happens. | |
347 * | 347 * |
348 * The [padding] must have length 1. | 348 * If [padding] has length different from 1, the result will not |
| 349 * have length `width`. This may be useful for cases where the |
| 350 * padding is a longer string representing a single character, like |
| 351 * `" "` or `"\u{10002}`". |
| 352 * In that case, the user should make sure that `this.length` is |
| 353 * the correct measure of the strings length. |
349 */ | 354 */ |
350 String padLeft(int newLength, String padding); | 355 String padLeft(int width, [String padding = ' ']); |
351 | 356 |
352 /** | 357 /** |
353 * Pads this string on the right if it is shorther than [newSize]. | 358 * Pads this string on the right if it is shorther than [width]. |
354 * | 359 * |
355 * Return a new string that append [padding] after this string | 360 * Return a new string that appends [padding] after this string |
356 * until the total length is [newLength]. | 361 * one time for each position the length is less than [width]. |
357 * | 362 * |
358 * If [newLength] is already smaller than or equal to `this.length`, | 363 * If [width] is already smaller than or equal to `this.length`, |
359 * no padding will happen. A negative `newLength` is allowed, | 364 * no padding is added. A negative `width` is treated as zero. |
360 * but no padding happens. | |
361 * | 365 * |
362 * The [padding] must have length 1. | 366 * If [padding] has length different from 1, the result will not |
| 367 * have length `width`. This may be useful for cases where the |
| 368 * padding is a longer string representing a single character, like |
| 369 * `" "` or `"\u{10002}`". |
| 370 * In that case, the user should make sure that `this.length` is |
| 371 * the correct measure of the strings length. |
363 */ | 372 */ |
364 String padRight(int newLength, String padding); | 373 String padRight(int width, [String padding = ' ']); |
365 | 374 |
366 /** | 375 /** |
367 * Returns true if this string contains a match of [other]: | 376 * Returns true if this string contains a match of [other]: |
368 * | 377 * |
369 * var string = 'Dart strings'; | 378 * var string = 'Dart strings'; |
370 * string.contains('D'); // true | 379 * string.contains('D'); // true |
371 * string.contains(new RegExp(r'[A-Z]')); // true | 380 * string.contains(new RegExp(r'[A-Z]')); // true |
372 * | 381 * |
373 * If [startIndex] is provided, this method matches only at or after that | 382 * If [startIndex] is provided, this method matches only at or after that |
374 * index: | 383 * index: |
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
708 _position = position - 1; | 717 _position = position - 1; |
709 _currentCodePoint = _combineSurrogatePair(prevCodeUnit, codeUnit); | 718 _currentCodePoint = _combineSurrogatePair(prevCodeUnit, codeUnit); |
710 return true; | 719 return true; |
711 } | 720 } |
712 } | 721 } |
713 _position = position; | 722 _position = position; |
714 _currentCodePoint = codeUnit; | 723 _currentCodePoint = codeUnit; |
715 return true; | 724 return true; |
716 } | 725 } |
717 } | 726 } |
OLD | NEW |