Lets say:
var = "8rk3pd"
Is there a way to check if the var has letters/numbers?
Lets say:
var = "8rk3pd"
Is there a way to check if the var has letters/numbers?
Hi NiKxzsu,
local var = "8rk3pd" -- The string.
print(var:match("%a+")) -- Prints 'rk' because that's the first combination of letters. %a is the string pattern for letters, and the '+' sign indicates that I want a sequence of them if possible. So, it returns rk rather than just r.
###Anyways, that's one way to do it. But, if you're interested in printing all of the letters from a string, you would loop through them using a for each iteration. Like:
local var = "8rk3pd" -- The string.
for i in string.gmatch(var, "%a+") do -- Will take the string and go through it to find sequences of letters. If you want to print each letter individually rather than sequences, you just need to remove the '+' sign.
print(i) -- Prints the letter that it's iterating through.
end -- end for for each iteration.
###If you want to change any of the above code to do just numbers, then you can simply change the string patterns, which can be found here.
##Well, I hope I helped and have a nice day/night.
Thanks,
Best regards,
~~ KingLoneCat
This discussion is preserved as it was. New answers, comments, and votes are closed.