dugasz1 Posted April 20, 2014 Share Posted April 20, 2014 Hello! How can i filter only the latin characters?(I don't know how it's called) (There are the allowed characters: qwertzuiopasdfghjklyxcvbnm. Is there a simple solution?) For example: name1 = "Sam ß Winchester" --==> Wrong! name2 = "Sam% Wichester" --==> Wrong! name3 = "Sám Wínchestér" --==> Wrong! name4 = "Sam Winchester" --==> Ok! name4 = "Robert J Thommas" --==> Ok! There are the allowed characters: Link to comment
csiguusz Posted April 20, 2014 Share Posted April 20, 2014 name1 = "Sam ß Winchester" --==> Wrong! name2 = "Sam% Wichester" --==> Wrong! name3 = "Sám Wínchestér" --==> Wrong! name4 = "Sam Winchester" --==> Ok! name4 = "Robert J Thommas" --==> Ok! function isValid ( name ) name = name:upper () for char in name:gmatch ( "." ) do local code = char:byte () if (code < 65 or code > 90) and code ~= 32 then return false end end return true end outputChatBox ( tostring ( isValid ( name1 ) ) ) outputChatBox ( tostring ( isValid ( name2 ) ) ) outputChatBox ( tostring ( isValid ( name3 ) ) ) outputChatBox ( tostring ( isValid ( name4 ) ) ) Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now