Jump to content

Only allowed charaters


dugasz1

Recommended Posts

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
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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...