RegExp vs indexOf (v3)

Revision 3 of this benchmark created by ConsciousCode on


Description

Compare speed of Regex with indexOf for finding XML entities

Setup

var isPresent=/&[#-\w];/g,
        url = "Lambda (λ) is a Greek letter.";

Test runner

Ready to run.

Testing in
TestOps/sec
Regex
if ( -1 != url.search(isPresent) ) {
  // no op
}
ready
indexOf
if ( -1 != url.indexOf('&') ) {
  // no op
}
ready

Revisions

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