function theissue(l) --yea basically this wont detect if the string is upper case or lower case i have no idea what im doing wrong here local typ = "" if string.upper(l) then typ = "upper" else typ = "lower" end print(typ) end
Basically it wont detect if the string is upper case i dont know what i am doing wrong but apparently im doing something wrong i guess
string.upper()
only just returns the string with all the letters in uppercase, it doesnt return if theres uppercase nor lowercase letters inside the string. you'd use string.match()
and the %u pattern.
local function theissue(L) -- use local functions local typ if string.match(L, "%u") then typ = "upper" else typ = "lower" end end
though this would only detect if theres a letter thats uppercase, not the entire string. if you'd want to find out if the entire string is uppercase then you could loop through it.
local function theissue(L) local typ = "upper" for letter in string.gmatch(L, "%a") do if not string.match(letter,"%u") then -- if it finds a lowercase letter typ = "lower" break -- breaks the loop end end print(typ) end
the %a pattern is every letter in a string.
Here's a function to check if it is uppercase.
function IsUpper(s) return (s == string.upper(s)); end