Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How can I get a specific letter of a variable?

Asked by 5 years ago

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?

0
print(string.sub("hello",2)) --> ello mattchew1010 396 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

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"

0
Note you could use Variable:sub(m,n) but that's not usually used. SoftlockedUnderZero 668 — 5y
0
That is very used wym it's not, it's even better than indexing the string table for sub User#24403 69 — 5y
0
Its your opinion SoftlockedUnderZero 668 — 5y
Ad

Answer this question