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

Revision 34 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.

Added case sensitivity to search

Preparation HTML

<script>
  var str = 'INLINE-block';
  var arr = ['inline', 'inline-block', 'inline-table', 'ruby'];
  var obj = {'inline': true, 'inline-block': true, 'inline-table': true, 'ruby': true};
</script>

Setup

var findThis = /(inline|ruby)/gi;

Test runner

Ready to run.

Testing in
TestOps/sec
test
findThis.test(str);
ready
search
str.search(findThis) > -1;
ready
exec
findThis.exec(str);
ready
match()
str.match(findThis) > 0;
ready
indexOf()
str.indexOf(findThis) > -1;
ready
string search
str.search('inline') > -1 && str.search('ruby') > -1;
ready
string indexOf
str.indexOf('inline') > -1 && str.indexOf('ruby') > -1;
ready
string match
str.match('inline') > -1 && str.match('ruby') > -1;
ready

Revisions

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