Javascript error regex not a function?
<p>I found some code online (stackoverflow <a href="http://stackoverflow.com/a/5774234/150062">http://stackoverflow.com/a/5774234/150062</a>) that does exactly what I need. But I can't seem to get it running. I get an error <code>"'/(\\d+)\\s*(second|min|minute|hour)/g' is not a function (evaluating 'regex(s)')";</code></p>

<pre><code>var timespanMillis = (function() {
  var tMillis = {
    second: 1000,
    min: 60 * 1000,
    minute: 60 * 1000,
    hour: 60 * 60 * 1000 // etc.
  };
  return function(s) {
    var regex = /(\d+)\s*(second|min|minute|hour)/g, ms=0, m, x;
    while (m = regex(s)) {
      x = Number(m[1]) * (tMillis[m[2]]||0);
      ms += x;
    }
    return x ? ms : NaN;
  };
})();
</code></pre>

<p>I've never heard of this <code>regex()</code> function either? Is it suppose to be something else?</p>
