Chromium Code Reviews| Index: sdk/lib/core/string.dart |
| diff --git a/sdk/lib/core/string.dart b/sdk/lib/core/string.dart |
| index 90e6b508b6b14eacbb5985033be2aa3814879207..8366764cab00681c103685058e6069f499e57d05 100644 |
| --- a/sdk/lib/core/string.dart |
| +++ b/sdk/lib/core/string.dart |
| @@ -463,11 +463,30 @@ abstract class String implements Comparable<String>, Pattern { |
| String replaceAllMapped(Pattern from, String replace(Match match)); |
| /** |
| - * Splits the string at matches of [pattern]. Returns |
| - * a list of substrings. |
| + * Splits the string at matches of [pattern] and returns a list of substrings. |
| * |
| - * Splitting with an empty string pattern (`''`) splits at UTF-16 code unit |
| - * boundaries and not at rune boundaries: |
| + * Finds all the matches of `pattern` in this string, |
| + * and returns the list of the substrings between the matches. |
| + * |
| + * var string = "Hello world!"; |
| + * string.split(" "); // ['Hello', 'world!']; |
| + * |
| + * Empty matches at the beginning and end of the strings are ignored, |
| + * and so are empty matches right after another match. |
| + * |
| + * var string = "abba"; |
| + * string.split(new RegExp(r"b*")); // ['a', 'a'] |
| + * // not ['', 'a', 'a', ''] |
| + * |
| + * If this string is empty, the result is an empty list if `pattern` matches |
| + * the empty string, and it is `[""]` if the pattern doesn't match. |
| + * |
| + * var string = ''; |
| + * string.split(''); // [] |
| + * string.split("a"); // [''] |
| + * |
| + * Splitting happends at UTF-16 code unit boundaries, |
|
Søren Gjesse
2014/10/27 08:35:04
Add 'NOTE:'
Lasse Reichstein Nielsen
2014/10/28 10:15:04
I try to avoid writing "NOTE" or "NOTICE" unless s
|
| + * and not at rune boundaries: |
| * |
| * var string = 'Pub'; |
| * string.split(''); // ['P', 'u', 'b'] |
| @@ -480,11 +499,11 @@ abstract class String implements Comparable<String>, Pattern { |
| * string = '\u{1D11E}'; |
| * string.split('').length; // 2 |
| * |
| - * You should [map] the runes unless you are certain that the string is in |
| - * the basic multilingual plane (meaning that each code unit represents a |
| - * rune): |
| + * To get a list of strings containing the individual runes of a string, |
| + * you should not use split. You can instead map each rune to a string |
| + * as follows: |
| * |
| - * string.runes.map((rune) => new String.fromCharCode(rune)); |
| + * string.runes.map((rune) => new String.fromCharCode(rune)).toList(); |
| */ |
| List<String> split(Pattern pattern); |