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 [newLength]. |
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 [newLength]. |
343 * | 344 * |
344 * If [newLength] is already smaller than or equal to `this.length`, | 345 * If [newLength] is already smaller than or equal to `this.length`, |
345 * no padding will happen. A negative `newLength` is allowed, | 346 * no padding will happen. A negative `newLength` is allowed, |
sra1
2014/02/19 21:18:09
Maybe: happen -> be added.
Lasse Reichstein Nielsen
2014/02/20 07:16:40
Done.
| |
346 * but no padding happens. | 347 * but no padding happens. |
347 * | 348 * |
348 * The [padding] must have length 1. | 349 * If [padding] has length different from 1, the result will not |
350 * have length `newLength`. This may be useful for cases where the | |
351 * padding is a longer string representing a single character, like | |
352 * `" "` or `"\u{10002}`". | |
353 * In that case, the user should make sure that `this.length` is | |
354 * the correct measure of the strings length. | |
349 */ | 355 */ |
350 String padLeft(int newLength, String padding); | 356 String padLeft(int newLength, [String padding = ' ']); |
sra1
2014/02/19 21:18:09
I think 'width' is a better name than 'newLength'.
Lasse Reichstein Nielsen
2014/02/20 07:16:40
Done.
| |
351 | 357 |
352 /** | 358 /** |
353 * Pads this string on the right if it is shorther than [newSize]. | 359 * Pads this string on the right if it is shorther than [newLength]. |
354 * | 360 * |
355 * Return a new string that append [padding] after this string | 361 * Return a new string that appends [padding] after this string |
356 * until the total length is [newLength]. | 362 * one time for each position the length is less than [newLength]. |
357 * | 363 * |
358 * If [newLength] is already smaller than or equal to `this.length`, | 364 * If [newLength] is already smaller than or equal to `this.length`, |
359 * no padding will happen. A negative `newLength` is allowed, | 365 * no padding will happen. A negative `newLength` is allowed, |
360 * but no padding happens. | 366 * but no padding happens. |
361 * | 367 * |
362 * The [padding] must have length 1. | 368 * If [padding] has length different from 1, the result will not |
369 * have length `newLength`. This may be useful for cases where the | |
370 * padding is a longer string representing a single character, like | |
371 * `" "` or `"\u{10002}`". | |
372 * In that case, the user should make sure that `this.length` is | |
373 * the correct measure of the strings length. | |
363 */ | 374 */ |
364 String padRight(int newLength, String padding); | 375 String padRight(int newLength, [String padding = ' ']); |
365 | 376 |
366 /** | 377 /** |
367 * Returns true if this string contains a match of [other]: | 378 * Returns true if this string contains a match of [other]: |
368 * | 379 * |
369 * var string = 'Dart strings'; | 380 * var string = 'Dart strings'; |
370 * string.contains('D'); // true | 381 * string.contains('D'); // true |
371 * string.contains(new RegExp(r'[A-Z]')); // true | 382 * string.contains(new RegExp(r'[A-Z]')); // true |
372 * | 383 * |
373 * If [startIndex] is provided, this method matches only at or after that | 384 * If [startIndex] is provided, this method matches only at or after that |
374 * index: | 385 * index: |
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
708 _position = position - 1; | 719 _position = position - 1; |
709 _currentCodePoint = _combineSurrogatePair(prevCodeUnit, codeUnit); | 720 _currentCodePoint = _combineSurrogatePair(prevCodeUnit, codeUnit); |
710 return true; | 721 return true; |
711 } | 722 } |
712 } | 723 } |
713 _position = position; | 724 _position = position; |
714 _currentCodePoint = codeUnit; | 725 _currentCodePoint = codeUnit; |
715 return true; | 726 return true; |
716 } | 727 } |
717 } | 728 } |
OLD | NEW |