title: Why does Javascript's regex.exec() not always return the same value?
body: <p>In the Chrome or Firebug console:</p>
  
  <pre><code>reg = /ab/g
  str = "abc"
  reg.exec(str)
     ==&gt; ["ab"]
  reg.exec(str)
     ==&gt; null
  reg.exec(str)
     ==&gt; ["ab"]
  reg.exec(str)
     ==&gt; null
  </code></pre>
  
  <p>Is exec somehow stateful and depends on what it returned the previous time? Or is this just a bug? I can't get it to happen all the time. For example, if 'str' above were "abc abc" it doesn't happen.</p>