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

Revision 3 of this benchmark created by john on


Preparation HTML

<script>
  var str = 'jj.rozario@yahoo.com';
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
test
/^(([a-zA-Z0-9]+(\.|\_|\-)?)+[a-zA-Z0-9])+@(([a-zA-Z0-9]+(\.|\_|\-)?)+[a-zA-Z0-9])+[.][a-z]{2,6}$/.test(str);
ready
search
str.search(/^(([a-zA-Z0-9]+(\.|\_|\-)?)+[a-zA-Z0-9])+@(([a-zA-Z0-9]+(\.|\_|\-)?)+[a-zA-Z0-9])+[.][a-z]{2,6}$/) > -1;
ready
match
str.match(/^(([a-zA-Z0-9]+(\.|\_|\-)?)+[a-zA-Z0-9])+@(([a-zA-Z0-9]+(\.|\_|\-)?)+[a-zA-Z0-9])+[.][a-z]{2,6}$/).length > 0;
ready
indexOf
str.indexOf(/^(([a-zA-Z0-9]+(\.|\_|\-)?)+[a-zA-Z0-9])+@(([a-zA-Z0-9]+(\.|\_|\-)?)+[a-zA-Z0-9])+[.][a-z]{2,6}$/) > -1;
ready

Revisions

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