split
优质
小牛编辑
136浏览
2023-12-01
Creates a Sequence comprising all of the substrings of this string separated by the given delimiter, which can be either a string or a regular expression.
Signature
StringLikeSequence.split = function(delimiter) { /*...*/ }
StringLikeSequence.split = function split(delimiter) { return new SplitStringSequence(this, delimiter); }
Name | Type(s) | Description |
---|---|---|
delimiter | string|RegExp | The delimiter to use for recognizing substrings. |
returns | Sequence | A sequence of all the substrings separated by the given delimiter. |
Examples
Lazy("foo").split("") // sequence: ["f", "o", "o"] Lazy("yo dawg").split(" ") // sequence: ["yo", "dawg"] Lazy("bah bah\tblack sheep").split(/\s+/) // sequence: ["bah", "bah", "black", "sheep"]