regex to match several string in Python
<p>I have questions with regex in Python.</p>

<p>Possible variations can be </p>

<p>10 hours, 12 weeks or 7 business days.</p>

<p>I want to have my regex something like </p>

<pre><code>string = "I have an 7 business day trip and 12 weeks vacation."
re.findall(r'\d+\s(business)?\s(hours|weeks|days)', string)
</code></pre>

<p>so that I expect to find "7 business day" and "12 weeks" but it returns None</p>

<p>You need to tweak your regex to this:</p>

<pre><code>&gt;&gt;&gt; string = "I have an 7 business day trip and 12 weeks vacation."
&gt;&gt;&gt; print re.findall(r'(\d+)\s*(?:business day|hour|week)s?', string)
['7', '12']
</code></pre>

<p>This matches any number that is followed by <code>business day</code> or <code>hour</code> or <code>week</code> and an optional <code>s</code> in the end.</p>

python regex