-- string.sub(s, i, j) is 1-based and inclusive local s = "hello world" print(string.sub(s, 1, 5)) -- negative indices count from the end print(string.sub(s, -5))
string.sub slices by index