Mgamerz icon

Untitled

Mgamerz | PRO | 03/20/14 02:13:01 AM UTC | 0 ⭐ | 194 👁️ | Never ⏰ | []
text |

1 KB

|

None

|

0 👍

/

0 👎

def check_regex_alphabet(regexp):
    ''' 
    This checks to make sure the input regex does not contain any erroneous characters.
    Since the input length is limited to 150 characters this is not time intensive operation in terms of CPU overhead. 
    '''
    alphabet = [' ', 'a', 'b', 'm', 'p', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '.', '\'', '\"', '/', '<', '>', '=', '~', '|', '*', '(', ')']
    for char in regexp:
        if char not in alphabet:
            return False
     return True
def check_string_alphabet(string):
    ''' 
    This checks to make sure the input string does not contain any erroneous characters.
    Since the input length is limited to 150 characters this is not time intensive operation in terms of CPU overhead. 
    '''
     alphabet = [' ', 'a', 'b', 'm', 'p', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '.', '\'', '\"', '/', '<', '>', '=', '~']
    for char in string:
        if char not in alphabet:
            return False
     return True

Comments