title: Javascript Regex - Find all possible matches, even in already captured matches
body: <p>I'm trying to obtain <em>all possible matches</em> from a string using regex with javascript. It appears that my method of doing this is not matching parts of the string that have already been matched.</p>
  
  <p>Variables:</p>
  
  <pre class="lang-js prettyprint-override"><code>var string = 'A1B1Y:A1B2Y:A1B3Y:A1B4Z:A1B5Y:A1B6Y:A1B7Y:A1B8Z:A1B9Y:A1B10Y:A1B11Y';
  
  var reg = /A[0-9]+B[0-9]+Y:A[0-9]+B[0-9]+Y/g;
  </code></pre>
  
  <p>Code:</p>
  
  <pre class="lang-js prettyprint-override"><code>var match = string.match(reg);
  </code></pre>
  
  <p>All matched results I get:</p>
  
  <pre class="lang-js prettyprint-override"><code>A1B1Y:A1B2Y
  A1B5Y:A1B6Y
  A1B9Y:A1B10Y
  </code></pre>
  
  <p>Matched results I want:</p>
  
  <pre class="lang-js prettyprint-override"><code>A1B1Y:A1B2Y
  A1B2Y:A1B3Y
  A1B5Y:A1B6Y
  A1B6Y:A1B7Y
  A1B9Y:A1B10Y
  A1B10Y:A1B11Y
  </code></pre>
  
  <p>In my head, I want <code>A1B1Y:A1B2Y</code> to be a match along with <code>A1B2Y:A1B3Y</code>, even though <code>A1B2Y</code> in the string will need to be part of two matches.</p>