08-31-2017
08/31/2017
08312017
8-31/2017
831,2017
Today
Tomorrow
You get the picture...
Teaching a machine to recognize a date can be challenging, especially given so many edge cases including leap years and formatting.
Using the concept of regex (i.e. regular expressions) and the idea behind an FSA (i.e. finite state automata), I decided to implement a class in Python to recognize whether or not certain inputs correspond to a dates. My code deterministically works on all inputs with separators such as "/" and "-" and on dates with leading zeros for months (i.e. "01", "02" ... "12").