substring(s, start, end)
Return a copy of the string s
from start
(inclusive) to end
(exclusive).
Start
and end
must be exact nonnegative integers; start
must be less than the
length of s
, while end
may be less than or equal to the length of s
.
If end <= start
is true
, a string of length zero is returned.
let s = "hello, world"
substring(s, 7, 9)
// wo
substring(s, 7, string_length(s))
// world
s[7:9]
// wo
s[7:]
// world
s[:5]
// hello