exec() vs match() vs test() vs search() vs indexOf() (v53)

Revision 53 of this benchmark created by Derek on


Description

Tests to determine which function is faster for detecting whether a string matches a regex pattern.

Test runner

Ready to run.

Testing in
TestOps/sec
substr()
if ("http://abcdef".substr(0,3) == "http") {
 // String matches regex
}
ready
match()
if ("http://abcdef".match(/^https?:/) !== null) {
 // String matches regex
}
ready

Revisions

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