Olle Risk Posted August 11, 2015 Posted August 11, 2015 Hello, Does anyone know how I can block non English languages in the chat, I'm using a custom chat system where the message is stored in a variable called "message" which is then printed using outputChatBox. Now my question is, how do I check this variable so that it only contains a set of allowed symbols like A-Z, a-z, 0-9 and a few symbols more? What function do I use?
anumaz Posted August 11, 2015 Posted August 11, 2015 Two ways. First way is making a table of allowed characters and then returning an error if your string contains a character not listed in that tab. Second way is with string.match and string.find with patterns. The patterns are: . --- (a dot) represents all characters. %a --- all letters. %c --- all control characters. %d --- all digits. %l --- all lowercase letters. %p --- all punctuation characters. %s --- all space characters. %u --- all uppercase letters. %w --- all alphanumeric characters. %x --- all hexadecimal digits. %z --- the character with hex representation 0x00 (null). %% --- a single '%' character. %1 --- captured pattern 1. %2 --- captured pattern 2 (and so on). %f[s] transition from not in set 's' to in set 's'. %b() balanced nested pair ( ... ( ... ) ... )
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