Question: Alright I'm trying to allow user input to include only letters, numbers, and dashes. Any other characters would be invalid. I also only want the characters to be 1-9 characters in length. 
Here is what I have so far:

```
def main():
    tag = input("Please enter your ID Tag: ")
    while(not rSeriesValidate(tag)):
        print("INVALID ID: Try again")
        tag = input("Please reenter your ID Tag: ")

    print("VALID ID. Move along, move along.")  

def rSeriesValidate(tag):
    isValid = True

    if(len(tag)<1 or len(tag)> 9):
        isValid = False
    elif(not tag.isalnum()):
        isValid = False

    return isValid

main()

```

With this I am able to make sure the worker inputs letters between 1-9 and that they are letters or numbers. However I can't figure out how to also allow dashes "-" to be inputted. Any suggestions? 
Thank you

Answer: 
If you don't want to use regular expressions, try simply going character by character:

```
def rSeriesValidate(tag):

    if len(tag) < 1 or len(tag) > 9:
        return False

    for currChar in tag:
        if not currChar.isalnum() and currChar != "-":
            return False

    return True

```

This first checks for the input length requirement, and returns False if it is not met. For input of suitable length, it goes on to check each character of the input. If it finds a disallowed character (one that is not alphanumeric and not a dash), it returns False.
Use `regex` to solve your problem. Example below:

```
import re

#pattern to search for any character other then [- A-Z a-z 0-9]
pattern = r'[^\-A-Za-z0-9]'

def check_str(sample_str):
    if re.search(pattern, sample_str):
        #Character other then [- A-Z a-z 0-9] was found
        print('Invalid : {}'.format(sample_str))
    else:
        #Character other then [- A-Z a-z 0-9] was not found
        print('Valid : {}'.format(sample_str))

check_str('AB-12')
check_str('AB-12#')
check_str('_-/>"!@#AB-12<')

#output
>>Valid : AB-12                                                                                                           
>>Invalid : AB-12#                                                                                                        
>>Invalid : _-/>"!@#AB-12<

```