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

Revision 4 of this benchmark created on


Description

Testing for the existence of characters in a string using Regular Expressions test, search, and match compared to indexOf.

Preparation HTML

<script>
  var str = 'dgird sy Eskk nsty';
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
test
/((sknsty|esk\s?n|e(s|ks|k|sks)nsty|esk[ky]?\s?nsty|esksn?ty|esk-nsty)|^esk$)/i.test(str);
ready
search
str.search(/((sknsty|esk\s?n|e(s|ks|k|sks)nsty|esk[ky]?\s?nsty|esksn?ty|esk-nsty)|^esk$)/i) > -1;
ready
match
str.match(/((sknsty|esk\s?n|e(s|ks|k|sks)nsty|esk[ky]?\s?nsty|esksn?ty|esk-nsty)|^esk$)/i).length > 0;
ready
indexOf
str.indexOf(/((sknsty|esk\s?n|e(s|ks|k|sks)nsty|esk[ky]?\s?nsty|esksn?ty|esk-nsty)|^esk$)/i) > -1;
ready

Revisions

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