title: Using python regex to capture one to three words after keyword
body: <p>I am trying to capture the one to three words after my keyword but some of my cases are not returning all the words. Here are three example strings and the expected output:</p>
  
  <ul>
  <li>"wait 5h 1m 2s" to ['5h 1m 2s']</li>
  <li>"wait a 5h 1m" to ['5h 1m']</li>
  <li>"wait 1m" to ['1m']</li>
  </ul>
  
  <p>I am trying to use regex because the example strings could be part of a more complicated line. This is my code:</p>
  
  <pre><code>In [51]: ex = re.compile('wait (?:A\s)?(\w+\s?\w+?\s?\w+?\s?)', re.IGNORECASE)
  
  In [52]: ex.findall("wait 5h 1m 2s")
  
  Out[52]: ['5h 1m ']
  
  In [53]:ex.findall("wait a 5h 1m")
  
  Out[53]: ['5h 1m']
  
  In [54]: ex.findall("wait 5h")
  
  Out[54]: []
  </code></pre>
  
  <p>Why is the regex not capturing the word after 'wait' and the two optional words?</p>