fork download
  1. import re
  2. def testChatChars(string):
  3. return re.search('[^\x20-\x5A\x5C\x5E-\x7E]|^$', string) is not None
  4.  
  5. print("testing Chat validation")
  6. print(testChatChars("") == False)
  7. print(testChatChars("this is a valid chat message") == True)
  8. print(testChatChars("9999abcdefghijklmnopqrxtuvxyz ABCDEFGHIJKLMNOP!@#$(^&*(&%$^^)*)!{},.;'\|?/7") == True )
  9. print(testChatChars("this is not [ valid chat message") == False)
  10. print(testChatChars("this is not ] valid chat message") == False)
  11. print(testChatChars("9999abcdefghijklmnopqrxtuvxyz [][][[][]ABCDEFGHIJKLMNOP!@#$(^&*(&%$^^)*)!{}[],.;'\|?/7ونِكود碼標準萬國") == False)
  12.  
  13.  
Success #stdin #stdout 0.06s 9568KB
stdin
Standard input is empty
stdout
testing Chat validation
False
False
True
False
False
False