title: Regex in javascript fails every other time with identical input
body: <p>A simple test script:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      var reg = new RegExp('#([a-f0-9]{3})$', 'gi');
      for (var i = 0; i &lt; 10; i++) {
          console.log(reg.exec('#fff'));
      }
  &lt;/script&gt;
  </code></pre>
  
  <p>Console output:</p>
  
  <pre><code>["#fff", "fff"]
  null
  ["#fff", "fff"]
  null
  ["#fff", "fff"]
  null
  ["#fff", "fff"]
  null
  ["#fff", "fff"]
  null
  </code></pre>
  
  <p><strong>Why is every other result null when the input remains constant?</strong></p>