Could I use "string.find" for this?
Thank you :)
You can detect how much character is in the string by using string.len(). Not to be confused, let me make an example and how is the concept:
Like a string called "LOL" have 3 character, we can use string.len("LOL")
and... It returns three! But what is the last letter at? It's at the 3rd column. Well it matches with the length! Also, we can use string.sub()
to get a specific place from the start to the end. Well, you wanted to locate the part only at the last letter. So what are we gonna do is:
local String = "I like apples" local String2 = "I like banana" print(string.sub(String, string.len(String), string.len(String))) -- s print(string.sub(String2, string.len(String2), string.len(String2))) -- a -- Not to be confused, string with capital s is the variable, and string with a small letter s is a built-in function
If you understand what I mean in the top and understood how it works, you can skip this. And mark this as an answer if this helped.
Also if you are confused, let me explain again, like "LOL" have 3 characters, the end is between the 3rd and the 3rd, that's how we locate one string letter. and string.len()
returns the string length and "LOL" have 3 character and the 3 is also the last letter (in column) of the string.
What the system sees are the string.sub()
of the string, as known as "LOL", get the letter between 3rd to 3rd, and the 3 comes from length.
Also if you want to make it lowercase or uppercase, use string.lower(String)
or string.upper(String)
Thank you for reading! Bye bye
Probably, but you can also use string.sub()
e.g.
local str = "Bruhlol MAIN" print(string.sub(str, 9)
which returns MAIN