I am aware there are numerous answers on SO about getting a date regex, but I am trying to create something readable in python.
I have come up with the following so far. Can someone review the below code?
def getDateRegex():
delim = r'[/\.\- ]'
dd = r'[0-3]*[0-9](st|th|nd){0,1}' # get a better 01-31 regex
mm = r'[0-1]*[0-9]' # get a better 01-12 regex
yyORyyyy = r'(?:[0-9]{2}){1,2}'
month = r'(Jan(uary)?|Feb(ruary)?|Mar(ch)?|Apr(il)?|May|Jun(e)?|Jul(y)?|Aug(ust)?|Sep(tember)?|Oct(ober)?|Nov(ember)?|Dec(ember)?)'
mmORmonth = r'({0}|{1})'.format(mm,month)
dd_mmORmonth_yyORyyyy = delim.join([dd, mmORmonth, yyORyyyy]) # format1
yyORyyyy_mmORmonth_dd = delim.join([yyORyyyy, mmORmonth, dd]) # format2
final_regex = r'({0}|{1})'.format(dd_mmORmonth_yyORyyyy,yyORyyyy_mmORmonth_dd)
return final_regex