Page 1 of 1
determining the nature of one character
Posted: Thu Mar 06, 2014 6:37 pm
by BenCharles
Hello,
Could someone please show me how to determine if the content of a one-character string is a letter and not a number?
Thank you
Re: determining the nature of one character
Posted: Thu Mar 06, 2014 7:41 pm
by micha
Try this:
Code: Select all
if tonumber(string) then
-- string is a number
else
-- string is something else
end
It works for multi-character strings, too.
Re: determining the nature of one character
Posted: Fri Mar 07, 2014 2:40 am
by BenCharles
Thank you that is excellent. Although it only works for identifying numbers, not letters, it's all I needed
Re: determining the nature of one character
Posted: Fri Mar 07, 2014 3:06 am
by Xgoff
Code: Select all
if your_string:match("%a") then
-- ...
end