title: How to match optional group at the end of string with regex?
body: <p>I have the strings like below: </p>
  
  <pre><code>(1) Pay for zone 1234 for 1 hour
  (2) Pay for zone 4567
  (3) Pay for zone 1234 for 1 hour 30 minutes
  </code></pre>
  
  <p>and the following regex (<a href="https://regex101.com/r/MBWJUq/1" rel="nofollow noreferrer">https://regex101.com/r/MBWJUq/1</a>):</p>
  
  <pre><code>(\d{4}).*(30 minutes|1 hour(?: 30 minutes)?|(?:[2-9]|1[0-9]|2[0-4]) hour(?: 30 minutes)?)
  </code></pre>
  
  <p>It works well with cases (1) and (3), but doesn't work with case (2). How should I fix it?</p>
  
  <p>It works with case (2), if I make last group optional. But then it doesn't capture first group with cases (1) and (3).</p>