match vs replace lenght count

Benchmark created by cyph00 on


Setup

var str = "1234567uUUUuuuuUUuuLL";

Test runner

Ready to run.

Testing in
TestOps/sec
replace
var x = str.replace(/[^0-9]/g,"").length;
ready
match
var x = str.match(/[^0-9]/g).length;
ready

Revisions

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