Regex doesn't filter out the right text on datatime
<p>I have a string below:</p>

<pre><code>senton = "Sent:                               Friday, June 18, 2010 12:57 PM"
</code></pre>

<p>I created a regex to filter out the datetime portion:</p>

<pre><code>reg_datetime = "(Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday), (January|February|March|April|May|June|July|August|September|October|November|December) \d{1,2}, \d{4} \d{2}:\d{2} (AM|PM)"
</code></pre>

<p>I tested the regex in regex101.com and it works as expected, however, when running it in my python test script, it fails to give me the right text, can anyone help me fix it?</p>

<p>Using it this way:</p>

<pre><code>real_senton = re.findall(reg_datetime, senton)
print real_senton
</code></pre>

<p>Produces this result (<a href="https://i.stack.imgur.com/Si8U8.jpg" rel="nofollow">here is the screenshot</a>):</p>

<pre><code>[('Friday', 'June', 'PM')]
</code></pre>

<p>Thank you very much.</p>

<p>without change <code>reg_datetime</code> and only use <code>search</code> </p>

<pre><code>import re
senton = "Sent:                               Friday, June 18, 2010 12:57 PM"
reg_datetime = "(Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday), (January|February|March|April|May|June|July|August|September|October|November|December) \d{1,2}, \d{4} \d{2}:\d{2} (AM|PM)"
l = re.search(reg_datetime,senton,re.M|re.I)
print l.group()
</code></pre>

<p>and run:</p>

<pre><code>$ python file.py
Friday, June 18, 2010 12:57 PM
$
</code></pre>

python regex