how would i get a certain character from a string?
for example, how would i get the third character from “abc”, which would be “c” in this case?
If you want to get the third character from a string, you can just do
string.sub(yourString,3,3)
Where yourString
is the string you want to take a certain character from and 3
being which position to take
Depending on the usecase, you may have to use something else. Like to find a certain character, you’d use string.match
string.match(yourString,"c")
If you wanted to check if a string had the letter c or not
Hey, I can help
string.sub("abc",3,3)
This would be the same for other strings obviously changing it to get the character you want.
Oops, Sorry I didn’t see you’d posted something similar
Completely fine! You still wanted to help and I respect that!
thanks, that works just about right
Anytime! If you have anymore issues don’t be afraid to make another post!
Sorry, but what does the second 3 do?
string.sub(str, s, e) is designed to return a string starting at s and ending at e. If you want to just get one character, you can use the same number for both s and e.