Skip to content

Instantly share code, notes, and snippets.

View skylander86's full-sized avatar
🎯
Focusing

Yanchuan Sim skylander86

🎯
Focusing
View GitHub Profile
@skylander86
skylander86 / date_regexes.py
Created December 25, 2018 05:52
Regular expressions for capturing dates
DATE_REGEXES = [
re.compile(r'\b(?P<year>199\d|200\d|201\d)[\-\u2010\u2014\u2013\.\_\/\s]{1,2}(?P<month>1|2|3|4|5|6|7|8|9|01|02|03|04|05|06|07|08|09|10|11|12)[\-\u2010\u2014\u2013\.\_\/\s]{1,2}(?P<day>1|2|3|4|5|6|7|8|9|01|02|03|04|05|06|07|08|09|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31)\b'), # 2017-09-28
re.compile(r'\b(?P<day>1|2|3|4|5|6|7|8|9|01|02|03|04|05|06|07|08|09|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31)[\-\u2010\u2014\u2013\.\_\/\s]{1,2}(?P<month>1|2|3|4|5|6|7|8|9|01|02|03|04|05|06|07|08|09|10|11|12)[\-\u2010\u2014\u2013\.\_\/\s]{1,2}(?P<year>199\d|200\d|201\d)\b'), # 28-9-2017
re.compile(r'\b(?P<month>1|2|3|4|5|6|7|8|9|01|02|03|04|05|06|07|08|09|10|11|12)[\-\u2010\u2014\u2013\.\_\/\s]{1,2}(?P<day>1|2|3|4|5|6|7|8|9|01|02|03|04|05|06|07|08|09|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31)[\-\u2010\u2014\u2013\.\_\/\s]{1,2}(?P<year>199\d|200\d|201\d)\b'), # 9-28-2017
re.compile(r'\b(?P<year>199\d|200\d|201\d)[\-\u2