How to I check that a string contains only digits and / in python?
Question: I am trying to check that a string contains only / and digits, to use as a
form of validation, however I cannot find and way to do both. ATM I have this:

    
    
    if Variable.isdigit() == False:
    

This works for the digits but I have not found a way to check also for the
slashes.


Answer: You could use the following regex.

    
    
    import re
    
    matched = re.match(r'^-?[0-9/]+$', '01/02/2016')
    if matched:
        print 'Matched integers with slashes'
    

