I would like to extract the last N characters from a Lua string.
What way I could use to achieve this?
Get the last character of string using len() function.
To get the last n characters from a string, we can use the stri_sub() function from a stringi package in R. The stri_sub() function takes 3 arguments, the first one is a string, second is start position, third is end position.
Use string.sub
with negative index.
Example
string.sub("Hello world", -5) -- => world
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With