# coding=utf8
# the above tag defines encoding for this document and is for Python 2.x compatibility
import re
regex = r"(Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?|Apr(?:il)?|May|June?|July?|Aug(?:ust)?|Sep(?:tember)?|Oct(?:ober)?|Nov(?:ember)?|Dec(?:ember)?)\s(\d\d?)(st|nd|rd|th)?,?\s(\d{4})|(\d\d?)[\.\/-](\d\d?)[\.\/-](\d{4})"
test_str = ("03.24.2014\n"
"Jan 13 2021\n"
"January 29, 2007\n"
"Jan 9 2003\n"
"12/25/2008\n"
"July 7th, 2022\n"
"03-16-2000\n"
"08-28-2020\n"
"June 21 2019\n"
"04-24-2008\n"
"October 31st 2018\n"
"June 20, 2000\n"
"August 29th 2005\n"
"Dec 12th, 2019\n"
"April 5 2004\n"
"Feb 7 2020\n"
"July 9th, 2011\n"
"Aug 18 2015\n"
"01.27.2020\n"
"December 27, 2022\n"
"04-05-2005\n"
"07/19/2001\n"
"08/21/1999\n"
"August 31st, 2004\n"
"November 18th 2015\n"
"Feb 25 2006\n"
"February 27th 2011\n"
"September 29th, 1999\n"
"Nov 13, 2017\n"
"Aug 19th 2014\n"
"Nov 24 1999\n"
"Oct 25 2015\n"
"11/01/2019\n"
"02/11/2017\n"
"11.30.2019\n"
"05.26.2002\n"
"Jan 14 1998\n"
"May 5, 1998\n"
"04-24-1998\n"
"November 23 2006\n"
"Mar 21, 1999\n"
"April 6, 2013\n"
"Jun 4th, 2012\n"
"Oct 16th, 2000\n"
"08/07/2021\n"
"May 8, 2003\n"
"October 30th, 2021\n"
"07/27/1998\n"
"03.30.2007\n"
"08/12/2005\n"
"May 23 2020\n"
"01/18/2019\n"
"09/04/2013\n"
"December 17, 2022\n"
"06.30.2012\n"
"Jul 23rd 2022\n"
"10.28.1998\n"
"February 16th 1998\n"
"05-20-2008\n"
"September 27th, 2002\n"
"03.27.2004\n"
"08/11/2015\n"
"May 29th, 2006\n"
"02-19-2005\n"
"02/08/2018\n"
"June 14, 2003\n"
"January 18th, 2000\n"
"Jun 9th 2022\n"
"02.12.2003\n"
"06/15/2015\n"
"April 16th, 2001\n"
"April 13th, 2011\n"
"Nov 7, 1998\n"
"02.19.2015\n"
"03/18/2009\n"
"12/19/2005\n"
"July 25th, 1998\n"
"08.06.2022\n"
"October 5, 2016\n"
"October 1, 2022\n"
"03-13-2013\n"
"06-03-1999\n"
"Nov 29th 2005\n"
"Jul 9, 2014\n"
"10-10-1999\n"
"August 19 2016\n"
"Apr 5, 2016\n"
"09.26.1999\n"
"10/15/2007\n"
"12.04.2018\n"
"12-08-2008\n"
"Jul 13, 2022\n"
"12.23.2006\n"
"December 8, 2011\n"
"June 4th 2004\n"
"10.07.2007\n"
"June 19th 2002\n"
"09.05.2011\n"
"December 15, 2009\n"
"12/17/2007\n"
"08-25-2017\n"
"September 13, 2000\n"
"11-29-2006\n"
"12-11-2000\n"
"01/25/2016\n"
"09/13/2014\n"
"Dec 30 2017\n"
"05/28/2018\n"
"January 31 2020\n"
"November 7th 2002\n"
"July 14 2008\n"
"08.31.2009\n"
"October 25 2018\n"
"01/09/1999\n"
"09/16/2007\n"
"04/01/2013\n"
"12-15-2000\n"
"Oct 16 2004\n"
"10.25.2009\n"
"Aug 7 2001\n"
"April 13th 2020\n"
"April 11th 2001\n"
"02/20/2011\n"
"Aug 4 2008\n"
"Jul 25 2017\n"
"November 1, 2010\n"
"July 7 2000\n"
"December 15, 2013\n"
"12.04.2018\n"
"03/21/2014\n"
"11/15/2004\n"
"September 6th, 2003\n"
"May 15th, 2010\n"
"February 7 2011\n"
"06/10/2021\n"
"02-13-2016\n"
"02.10.2012\n"
"08-20-1998\n"
"Aug 24, 2007\n"
"04.27.2014\n"
"03/08/2019\n"
"09-09-2020\n"
"September 10th, 2022\n"
"May 11th, 2002\n"
"11/05/2015\n"
"01-29-2003\n"
"Aug 27th, 2000\n"
"Oct 11, 2013\n"
"12/12/2002\n"
"Nov 16 2007\n"
"October 13th, 2008\n"
"10-12-2017\n"
"02/16/1999\n"
"04.13.2013\n"
"Aug 19, 2020\n"
"February 9th, 2018\n"
"Sep 27, 2002\n"
"April 27th, 2005\n"
"February 17, 2005\n"
"Apr 6 1998\n"
"July 17, 2020\n"
"10/22/2000\n"
"11/29/2019\n"
"Jan 5 2018\n"
"08/12/1998\n"
"10.07.1998\n"
"07/21/2021\n"
"03.22.2006\n"
"04-19-2002\n"
"Feb 26th, 2022\n"
"Mar 18 2017\n"
"February 10, 2013\n"
"September 24, 2021\n"
"07-14-2003\n"
"Feb 1st, 2019\n"
"March 23, 2022\n"
"11/22/2014\n"
"May 10 2014\n"
"Mar 13th, 2008\n"
"05.27.2014\n"
"Jun 22, 2010\n"
"Jun 26th 2020\n"
"Sep 7, 2002\n"
"June 19 2004\n"
"03-26-2015\n"
"07.27.2005\n"
"02/24/1998\n"
"February 13th 2010\n"
"08-18-2012\n"
"May 27 1999\n"
"August 7th 2001\n"
"07.27.2001\n"
"January 25 2006\n"
"07.31.2003\n"
"November 1st, 2007\n"
"04.13.2010\n"
"11.03.2021\n"
"Oct 6, 2019\n"
"February 10 2015\n"
"01.11.2000\n"
"05.16.2016\n"
"11.16.2019\n"
"01-16-2003\n"
"December 31st 2018\n"
"04.15.2014\n"
"Jul 17th 2007\n"
"11-07-2021\n"
"05-10-2007\n"
"02-01-2007\n"
"May 31st, 2004\n"
"July 4th 2018\n"
"Jun 28 2018\n"
"Nov 17 2002\n"
"Jun 24, 2006\n"
"March 26 2022\n"
"10/18/1998\n"
"Jul 2nd 1998\n"
"March 25th, 2020\n"
"Jul 30th 2021\n"
"08.24.2017\n"
"October 8, 2006\n"
"10.24.2002\n"
"May 8 2020\n"
"Apr 16th 2006\n"
"10.20.2005\n"
"05/05/2001\n"
"10/21/2020\n"
"05/20/2020\n"
"11/09/2015\n"
"12-16-2011\n"
"Nov 8, 2019\n"
"02-10-2015\n"
"September 26th 2012\n"
"May 11th 2020\n"
"Dec 23rd, 2005\n"
"May 14th 1998\n"
"01.16.2004\n"
"Oct 28 1999\n"
"July 5th 2006\n"
"05-09-2018\n"
"10.28.2017\n"
"Jun 1, 2004\n"
"Feb 3rd, 2002\n"
"07.31.2004\n"
"Jan 26 2009\n"
"12/04/2009\n"
"Jan 21st, 2020\n"
"February 18 2015\n"
"10.28.2018\n"
"Oct 16th, 2020\n"
"February 23, 2002\n"
"08-29-2001\n"
"August 22 2002\n"
"June 22nd, 2009\n"
"09.06.2006\n"
"Oct 14th 2003\n"
"October 24th, 2005\n"
"09-30-2000\n"
"September 24th 2007\n"
"11-19-2020\n"
"03-21-2004\n"
"02/24/2004\n"
"08/30/2011\n"
"September 27 2003\n"
"Aug 3 2003\n"
"August 15, 2014\n"
"October 17 2019\n"
"June 26th 2011\n"
"05.16.2021\n"
"12-21-2018\n"
"August 19th 2003\n"
"June 2nd, 2022\n"
"November 11th, 1999\n"
"August 10 2012\n"
"Jan 28th 2019\n"
"Jun 10th 2012\n"
"Jan 18th, 2014\n"
"October 30, 2015\n"
"April 21 2000\n"
"August 18 2002\n"
"September 1, 2014\n"
"Sep 9th 2003\n"
"09-16-2007\n"
"May 3rd, 2003\n"
"March 16, 2016\n"
"Jul 24 2002\n"
"08-19-1999\n"
"February 3, 2013\n"
"January 17 2010\n"
"11-12-2002\n"
"January 29 2006\n"
"04.24.2004\n"
"Aug 25, 2002\n"
"October 16 2001\n"
"August 15 2022\n"
"06-20-2011\n"
"06-27-2004\n"
"December 28, 2015\n"
"Apr 1st 2004\n"
"Sep 21, 2002\n"
"Oct 19th, 2007\n"
"August 12, 1999\n"
"January 29, 2012\n"
"04.01.1998\n"
"10.06.2021\n"
"October 31, 2012\n"
"April 28th, 2017\n"
"March 5, 2019\n"
"04/01/2016\n"
"03.12.2016\n"
"Dec 23rd, 2010\n"
"02-15-2022\n"
"January 14 2016\n"
"05/23/2019\n"
"07.10.2012\n"
"Sep 25th, 2001\n"
"10/14/2003\n"
"March 30th 2021\n"
"April 25th, 1999\n"
"Mar 20th 2015\n"
"Apr 17th, 2011\n"
"11-30-2007\n"
"04/21/2001\n"
"08/07/2006\n"
"November 15 2002\n"
"11-30-2014\n"
"07/26/2013\n"
"February 8, 2020\n"
"06.17.1999\n"
"01/13/2002\n"
"10/19/2009\n"
"12-20-2020\n"
"March 5 2001\n"
"10.05.2010\n"
"Feb 22nd, 2020\n"
"May 25th, 2013\n"
"12-06-1998\n"
"09.05.2013\n"
"05.09.2014\n"
"12/30/2016\n"
"May 2 2003\n"
"07.10.2006\n"
"07.17.2011\n"
"11/04/2006\n"
"April 29 2018\n"
"03-27-2005\n"
"May 1, 2006\n"
"02.23.2002\n"
"03.02.1998\n"
"12/12/2002\n"
"08-08-2002\n"
"08/31/2018\n"
"05-10-2011\n"
"07.10.2015\n"
"12.02.2012\n"
"Aug 4, 2022\n"
"06.12.2021\n"
"01.13.2020\n"
"October 1st 1998\n"
"August 19, 2013\n"
"Mar 18 2021\n"
"06.18.2009\n"
"08.12.2012\n"
"10-03-2022\n"
"04-21-2018\n"
"10/30/2015\n"
"May 14 2019\n"
"05/22/2012\n"
"02.18.2014\n"
"03.20.2022\n"
"01.09.2006\n"
"March 2 2014\n"
"Mar 16 2011\n"
"10-08-1999\n"
"09-14-2010\n"
"11.23.2002\n"
"April 28th, 2004\n"
"04-12-2007\n"
"June 1st 2003\n"
"July 2nd 2007\n"
"December 14, 2016\n"
"10/26/2019\n"
"February 11th 2015\n"
"February 12th, 2018\n"
"01/08/2004\n"
"September 22nd, 2004\n"
"August 17th, 2000\n"
"November 22nd 2021\n"
"June 10th 2003\n"
"Jul 17th 1999\n"
"09-01-2014\n"
"July 21st 2015\n"
"January 11 2013\n"
"03/04/2005\n"
"02-08-2018\n"
"Mar 20, 2001\n"
"04/03/2016\n"
"September 11, 2021\n"
"01/30/2016\n"
"April 8 2009\n"
"05/08/2010\n"
"Jan 15th 2008\n"
"02-13-2022\n"
"Apr 15th, 2016\n"
"Sep 4 2020\n"
"Nov 10, 2008\n"
"March 30 2014\n"
"07.27.2005\n"
"01.27.2021\n"
"June 9th 2021\n"
"Feb 23rd, 2020\n"
"06.05.2015\n"
"02-23-2000\n"
"Feb 12, 2020\n"
"May 1st 1998\n"
"03/08/2017\n"
"03-27-2007\n"
"July 13, 1998\n"
"01/01/2000\n"
"Apr 2, 1998\n"
"02.14.2014\n"
"Mar 22 2005\n"
"Jan 4 2012\n"
"08-28-2015\n"
"Jan 21st, 2015\n"
"Jul 7th, 2006\n"
"05-04-2004\n"
"Apr 4, 1999\n"
"11/04/2016\n"
"10-26-2009\n"
"June 22 2006\n"
"08/24/2022\n"
"12-14-2012\n"
"Feb 28, 2001\n"
"09/21/2000\n"
"Aug 24, 2016\n"
"October 22nd, 2001\n"
"June 21, 2005\n"
"August 27th, 2018\n"
"Feb 26th, 2020\n"
"February 14th, 2012\n"
"06.01.2008\n"
"07/20/2017\n"
"02.10.2022\n"
"July 27th 2009\n"
"10-08-2016\n"
"09/03/2005\n"
"Apr 12, 2005\n"
"Nov 22 2016\n"
"Mar 24, 2002\n"
"Sep 5, 1999\n"
"March 29th 1999\n"
"Feb 4, 1999\n"
"08/17/2002\n"
"November 13 2014\n"
"02-08-2013\n"
"Aug 1, 2009\n"
"Oct 8, 2015\n"
"03-20-2003\n"
"Mar 16, 2012\n"
"Nov 4 2017\n"
"Jan 28th, 2008\n"
"10-13-2017\n"
"Oct 24th 2012\n"
"Jul 11, 2003\n"
"Apr 17 2013\n"
"November 20th, 2020\n"
"09.06.2013\n"
"June 2, 2012\n"
"09/13/2010\n"
"Sep 28th, 2000\n"
"07-06-2005\n"
"Dec 13 2007\n"
"September 4 2004\n"
"June 20, 2010\n"
"12/28/2013\n"
"Mar 24 2004\n"
"March 8, 2012\n"
"02-18-2008\n"
"April 24 2013\n"
"02-27-2003\n"
"03.10.2022\n"
"Jul 18 2020\n"
"02-05-2004\n"
"03/26/2014\n"
"September 18th 1999\n"
"04/04/2021\n"
"June 10th, 2014\n"
"Jul 6th, 2007\n"
"April 21st 2022\n"
"09-17-2012\n"
"09/17/1999\n"
"03.22.1998\n"
"06/15/2000\n"
"January 11 2008\n"
"March 5, 1999\n"
"11/07/2011\n"
"04/22/2017\n"
"05-21-2012\n"
"Aug 2 2011")
matches = re.finditer(regex, test_str, re.MULTILINE)
for matchNum, match in enumerate(matches, start=1):
print ("Match {matchNum} was found at {start}-{end}: {match}".format(matchNum = matchNum, start = match.start(), end = match.end(), match = match.group()))
for groupNum in range(0, len(match.groups())):
groupNum = groupNum + 1
print ("Group {groupNum} found at {start}-{end}: {group}".format(groupNum = groupNum, start = match.start(groupNum), end = match.end(groupNum), group = match.group(groupNum)))
# Note: for Python 2.7 compatibility, use ur"" to prefix the regex and u"" to prefix the test string and substitution.
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Python, please visit: https://docs.python.org/3/library/re.html