Ok what i want to do is very specific.
I want to generate a random letter from A-Z then compare that letter to the first letter in a string.
1 Like
Random letter:
local randomLetter = string.char(math.random(97,122))
local s = "abc123"
local firstLetter= string.sub(s, 1, 1)
Compare:
--you will need lower case in order to compare characters
print(randomLetter:lower() == firstLetter:lower())
2 Likes
you could also do this
local String = "abc123"
local RandomCharacter = string.char(math.random(97,122))
if string.match(String:lower(), "^"..RandomCharacter:lower()) then
print("wow")
end
both options work
1 Like
This might be a stupid question but what does the String I and String J stand for.
This diagram should illustrate it:
It’s a thing you learn when learning string manipulation in any language.
Thank you! I’m new to editing strings with code and other things like that, You have been very helpful.
1 Like