当前位置: 首页 > 文档资料 > Lazy.js 英文文档 >

split

优质
小牛编辑
126浏览
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);
}
NameType(s)Description
delimiterstring|RegExp

The delimiter to use for recognizing substrings.

returnsSequence

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"]