substring

substring(string string, number start, [number length]) → string string
Extracts a substring, starting at start position and of given length, from given string.

Returns the substring of the string string starting from the character at index start and of length length.

Parameters
Return
Python

In Python, you take a slice: s[start:end] returns the characters from index start included to end excluded, so s[start:start + length] for a length length. Both bounds are optional (s[3:], s[:5]), a negative index counts from the end (s[-3:]), and a third number sets the step: "Hello world!"[2:10:2] is "lowr".

Examples

substring("Hello world!", 3) // "lo world!" substring("Hello world!", 3, 6) // "lo wor"

See also