I'm looking to take a variable and take the last few letters from it's contents, but doing the way you get a specific letter out of a string (("string",1,1)) doesn't work for a variable. Can someone tell me the syntax for doing that?
✓ ANSWER ACCEPTED
How can I get a specific letter of a variable?
1 answer
✓ Accepted answer
There is a table series called "string" (commonly used), to configure string values. In your case, you would want to use string.sub(target string,start of section number,end of section number). For example,
local var1 = "pineapple"
local var2 = string.sub(var1,5,7)
print(var2) --Should print "app"
3 comments
0
Note you could use Variable:sub(m,n) but that's not usually used.
0
That is very used wym it's not, it's even better than indexing the string table for sub
0
Its your opinion
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
print(string.sub("hello",2)) --> ello