title: Remove capture groups from a regex
body: <p>I have a regex 'simple' that I'd like to use as a building block for another regex 'complex'. The trouble is, the capture groups in 'simple' are interfering with 'complex'. These low level capture groups are details I don't to care about. I'd love to remove them before the regex is consumed. </p>
  
  <p>The question is: how?</p>
  
  <p>Put another way, in code, this isn't working well:</p>
  
  <pre><code>simple = /(a)bc/
  complex = /(#{simple}) - (#{simple})/
  complex.match("abc - abc").captures # =&gt; ["abc", "a", "abc", "a"]
  // when I need ["abc","abc"]
  </code></pre>
  
  <p>I'd much rather write:</p>
  
  <pre><code>simple = /(a)bc/
  complex = /(#{simple.without_capture}) - (#{simple.without_capture})/
  complex.match("abc - abc").captures # =&gt; ["abc", "abc"]
  </code></pre>
  
  <p>I'm a stuck on how to do this, but I'm betting it's been done before. The implementation of <code>Regex#without_capture</code> would need to of course account for non-capturing groups, look ahead/behind, etc. So simply removing all the () isn't enough. Also, finding the matching ) for capture groups seems a little challenging.</p>
  
  <p>Thoughts?</p>
  
  <p><strong>EDIT:</strong> I forgot to mention. I don't want to manually create two versions of simple (a capturing and non-capturing). In my actual case it would be impractical to maintain both versions. It'd be much better to be able to toggle the capturing dynamically.</p>