Regex ('foo'|'bar') notation
<p>I'm using regex to parse some time data, but my attempt is not matching as I would expect.  Here's my code:</p>

<pre><code>import re
print re.findall("\d+:\d+ (am|pm)", "11:30 am - 2:20 pm")
</code></pre>

<p>This produces <code>['am', 'pm']</code>, not <code>['11:30 am', '2:20 pm']</code>, which is what I want.</p>

<p>I can produce the result that I want with <code>\d+:\d+ am|\d+:\d+ pm</code>, but that is a little blunt and I want to know why the other is not working?</p>

<p>Your problem relates to capturing groups. If you want to have non-capturing alternation use the regex <code>\d+:\d+ (?:am|pm)</code>.</p>

python regex