Extract a substring from a string.
substr(string, start [, length])
string (string) - The string to extract fromstart (number) - Starting position (0-indexed)length (optional, number) - Number of characters to extract. If omitted, extracts to end of stringExtracted substring
Extract from start position:
text = "hello world"
print(substr(text, 0, 5)) // "hello"
print(substr(text, 6)) // "world"
Negative indices from end:
text = "hello"
print(substr(text, -2)) // "lo"
print(substr(text, -3, 2)) // "ll"
Extract characters:
word = "duso"
print(substr(word, 1, 2)) // "us"
print(substr(word, 0, 1)) // "d"