For example, my input for variable day can be Monday or Monday, Tuesday or Monday,..,Friday and I'm trying to use regex in python to just provide a pattern and check its input.
result = re.compile(r'\([S|M|T|W|Th|F|Sa]\)|\([S|M|T|W|Th|F|Sa],[S|M|T|W|Th|F|Sa]+\)')
day = "(T,Th)"
if result.match(day):
print "matched"
else:
print 'not'
What if the given input is (T,Th,F) or (T,Th,F,Sa)? What should I do to my pattern to handle these kind of input? Is there any solution so it wont be lengthy?
[]represents a character class,|is not anoroperation there. Use(S|M|T|W|Th|F|Sa)...