How do I get the second to last character from a string

Title says it all really
How can I get the second to last character from a string

1 Like

For second last character just subtract by one I believe

str:sub(#str-1, #str)
1 Like

That’s giving me both the last and second to last letter

1 Like

Alright str:sub(#str-1, #str-1) works

1 Like

When using string.sub, -1 will start counting from the end. So inputting -2 will give you the second to the last character.

str:sub(-2,-2) should work.

1 Like