title: Consuming a Lookaround or Ignoring a Non-Capture in a Regex match
body: <p>Consider the following string: <code>ABC</code>. I would like to capture the following groups using a regular expression:</p>
  
  <pre><code>Group1: AC
  Group2: B
  </code></pre>
  
  <p>Both the groups have to be captured using a single regular expression. I do not have control over the code, so sub-matches or capture groups will not help. </p>
  
  <p>I've tried both non-capturing groups and look arounds. </p>
  
  <p>With a Non-Capturing group, the match is still a part of the final result. </p>
  
  <pre><code>(?&lt;Group1&gt;a(?:(?&lt;Group2&gt;b))c)
  </code></pre>
  
  <p>Group1: ABC    # Not right as B is part of the match. Group2: B</p>
  
  <p>With a lookaround, Group2 is not consumed and the regex following the look ahead should match the contents of Group2 again which includes it as part of Group1.</p>
  
  <pre><code>(?&lt;Group1&gt;a(?=(?&lt;Group2&gt;b))bc)
  </code></pre>
  
  <p>Group1: ABC    # Not right as B is part of the match.
  Group2: B</p>
  
  <p>How can I ignore "B" as part of the Group1 match?</p>
  
  <p>Any help on getting around this is greatly appreciated.</p>
  
  <p>Thanks,
  Balaji</p>