How would I get the last letter of any string using Sub()? Would I have to use a hashtag? If so, how?
You can start from the end using negative endpoints, so doing str:sub(-1, -1)
will get you the last character.
4 Likes
You could use the length of the string to find the end: str:sub(#str, #str)
.
15 Likes
return string.sub(str, #str)
2 Likes