title: Regex for extracting all complex dates formats from a string in python
body: <p>I have following string: </p>
  
  <pre><code> dateEntries = "04-20-2009; 04/20/09; 4/20/09; 4/3/09; Mar 20, 2009; March 20, 2009; Mar. 20, 2009; Mar 20 2009; 20 Mar 2009; 20 March 2009; 2 Mar. 2009; 20 March, 2009; Mar 20th, 2009; Mar 21st, 2009; Mar 22nd, 2009; Feb 2009; Sep 2009; Oct 2010; 6/2008; 12/2009; 2009; 2010"
  </code></pre>
  
  <p>Here I want to extract all mentioned dates using <code>regex</code>. As an attempt I have written following <code>regex</code>:</p>
  
  <pre><code>import re
  
  regEx = r'(?:\d{1,2}[-/th|st|nd|rd\s]*)?(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)[a-z\s,.]*(?:\d{1,2}[-/th|st|nd|rd)\s,]*)?(?:\d{2,4})'
  
  re.findall(regEx, dateEntries)
  </code></pre>
  
  <p>I was expecting this to work but it only return subset of dates.</p>
  
  <pre><code>A = ['Mar 20, 2009',
   'March 20, 2009',
   'Mar. 20, 2009',
   'Mar 20 2009',
   '20 Mar 2009',
   '20 March 2009',
   '2 Mar. 2009',
   '20 March, 2009',
   'Mar 20th, 2009',
   'Mar 21st, 2009',
   'Mar 22nd, 2009',
   'Feb 2009',
   'Sep 2009',
   'Oct 2010']
  </code></pre>
  
  <p>I'm not getting why its not returning the dates:</p>
  
  <pre><code>B=[04-20-2009; 04/20/09; 4/20/09; 4/3/09; 6/2008; 12/2009; 2009; 2010"]
  </code></pre>
  
  <p>I created the <code>regEx</code> by extending the <code>r'(?:\d{1,2}[-\s\/])?(?:\d{1,2}[-\/\s])?(?:\d{2,4})'</code> which works good for set B. But <code>regEx</code> is not able to produce <code>A+B</code></p>
  
  <p>Can anyone help in making a regex for extracting all dates mentioned in my <code>dateEntries</code> ?</p>
  
  <p><strong>NOTE:</strong> I want to solve this using regex only.</p>