title: regex grouping doesn't seem to respect nested hierarchy
body: <p>I have these tests string :</p>
  <pre><code>abc optional def ghi
  
  abc def ghi
  </code></pre>
  <p>that both match this regex</p>
  <pre><code>(.+) ((optional \s*)?def)\s+(.+)
  </code></pre>
  <p><a href="https://regex101.com/r/0pZQEy/1" rel="nofollow noreferrer">https://regex101.com/r/0pZQEy/1</a></p>
  <p>but I want to group optional with def whereas it groups optional with abc, I can't see how to fix this</p>