title: Javascript Regex literal with /g used multiple times
body: <p>I have a weird issue working with the Javascript Regexp.exec function. When calling multiple time the function on new (I guess ...) regexp objects, it works one time every two. I don't get why at all!</p>
  
  <p>Here is a little loop example but it does the same thing when used one time in a function and called multiple times.</p>
  
  <pre><code>for (var i = 0; i &lt; 5; ++i) {
    console.log(i, (/(b)/g).exec('abc'));
  }
  
  &gt; 0 ["b", "b"]
  &gt; 1 null
  &gt; 2 ["b", "b"]
  &gt; 3 null
  &gt; 4 ["b", "b"]
  </code></pre>
  
  <p>When removing the /g, it gets back to normal.</p>
  
  <pre><code>for (var i = 0; i &lt; 5; ++i) {
    console.log(i, (/(b)/).exec('abc'));
  }             /* no g ^ */
  
  &gt; 0 ["b", "b"]
  &gt; 1 ["b", "b"]
  &gt; 2 ["b", "b"]
  &gt; 3 ["b", "b"]
  &gt; 4 ["b", "b"]
  </code></pre>
  
  <p>I guess that there is an optimization, saving the regexp object, but it seems strange.</p>
  
  <p>This behaviour is the same on Chrome 4 and Firefox 3.6, however it works as (I) expected in IE8. I believe that is intended but I can't find the logic in there, maybe you will be able to help me!</p>
  
  <p>Thanks</p>