RegExp test / search / match vs. indexOf (v82)

Revision 82 of this benchmark created on


Preparation HTML

<script>
  var str = '00000000-0000-1000-8080-808080808080';
</script>

Setup

var precompiledRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;

Test runner

Ready to run.

Testing in
TestOps/sec
precompiled indexOf
str.indexOf(precompiledRegex) > -1;
ready
precompiled match
str.match(precompiledRegex).length > 0;
ready
precompiled test
precompiledRegex.test(str);
ready
precompiled search
str.search(precompiledRegex) > -1;
ready
indexOf
str.indexOf(/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i) > -1;
ready
search
str.search(/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i) > -1;
ready
match
str.match(/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i).length > 0;
ready
test
/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(str);
ready

Revisions

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