Testing regex

JavaScript performance comparison

Test case created

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    var str = "{this} {is a} blah {test}";
};
</script>

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
While regex
var rex = /\{([^}]+)\}/g;
var m;
var parts = [];
for (m = rex.exec(str); m; m = rex.exec(str)) {
    parts.push(m[1]);
}
pending…
Map regex
var parts = str.match(/{[^}]+/g).map(function (s) { return s.slice(1); });
pending…

You can edit these tests or add even more tests to this page by appending /edit to the URL.

Compare results of other browsers

0 comments

Add a comment