substring
优质
小牛编辑
132浏览
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); }
Name | Type(s) | Description |
---|---|---|
start | number | The index where this sequence should begin. |
stop | number? | The index (exclusive) where this sequence should end. |
returns | StringLikeSequence | 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: ""