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

substring

优质
小牛编辑
136浏览
2023-12-01

Returns a StringLikeSequence comprising the characters from this sequence starting at start and ending at stop (exclusive), or---if stop is undefined, including the rest of the sequence.

Signature

StringLikeSequence.substring = function(start, stop) { /*...*/ }
StringLikeSequence.substring = function substring(start, stop) {
  return new StringSegment(this, start, stop);
}
NameType(s)Description
startnumber

The index where this sequence should begin.

stopnumber?

The index (exclusive) where this sequence should end.

returnsStringLikeSequence

The new sequence.

Examples

Lazy("foo").substring(1)      // sequence: "oo"
Lazy("foo").substring(-1)     // sequence: "foo"
Lazy("hello").substring(1, 3) // sequence: "el"
Lazy("hello").substring(1, 9) // sequence: "ello"
Lazy("foo").substring(0, 0)   // sequence: ""
Lazy("foo").substring(3, 3)   // sequence: ""