title: Optionally matching subgroup in regex
body: <p>I have a SQL string I'm trying to match using PHP <code>preg_match_all</code> and I need to extract out the matches. It looks like this:</p>
  
  <pre><code>A BUNCH OF MEANINGLESS SQL And (Condition1 = 'thisvalue*' Or Condition1 = '8504577' Or Condition1 = 'somethingelse123*') And MORE MEANINGLESS SQL
  </code></pre>
  
  <p>I want to grab all those <code>Condition1 = X</code> parts and use them in a different area, but ONLY if they are in the larger sub-condition in parentheses and are connected by <code>Or</code>s.</p>
  
  <p>My regex looks like this (<a href="https://www.regex101.com/r/gepdq9/3" rel="nofollow noreferrer">https://www.regex101.com/r/gepdq9/3</a>): </p>
  
  <pre><code>/(\((Condition1 = '[\dA-Za-z]+\*?'(\sOr\s)?)+\))/
  </code></pre>
  
  <p>It matches the larger sub-condition correctly, but for some reason the <code>matches[3]</code> item, which I think should be capturing all the <code>thisvalue*</code>, <code>8504577</code> and <code>somethingelse123*</code> values, is only capturing the last one.</p>
  
  <p>How can I capture all of these matches?</p>