Mgamerz

Untitled

Mar 19th, 2014
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. def check_regex_alphabet(regexp):
  2. '''
  3. This checks to make sure the input regex does not contain any erroneous characters.
  4. Since the input length is limited to 150 characters this is not time intensive operation in terms of CPU overhead.
  5. '''
  6. alphabet = [' ', 'a', 'b', 'm', 'p', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '.', '\'', '\"', '/', '<', '>', '=', '~', '|', '*', '(', ')']
  7. for char in regexp:
  8. if char not in alphabet:
  9. return False
  10.  
  11. return True
  12. def check_string_alphabet(string):
  13. '''
  14. This checks to make sure the input string does not contain any erroneous characters.
  15. Since the input length is limited to 150 characters this is not time intensive operation in terms of CPU overhead.
  16. '''
  17.  
  18. alphabet = [' ', 'a', 'b', 'm', 'p', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '.', '\'', '\"', '/', '<', '>', '=', '~']
  19. for char in string:
  20. if char not in alphabet:
  21. return False
  22.  
  23. return True
Advertisement
Add Comment
Please, Sign In to add comment