How to get last N characters of string in Lua? Use string.sub with negative index. Example string.sub("Hello world", -5) -- => world