Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
RegEx.test vs. String.includes vs. String.match with multiple searches
(version: 1)
Comparing performance of:
RegEx.test vs String.includes vs String.match
Created:
one year ago
by:
Guest
Jump to the latest result
Script Preparation code:
var string = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."; var searches = ['ipsum', 'tempor', 'foobar', 'dolore', 'est'] var regex = new RegExp(searches.join("|"));
Tests:
RegEx.test
regex.test(string);
String.includes
for (const search of searches) { if (string.includes(search)) break; }
String.match
string.match(regex);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
RegEx.test
String.includes
String.match
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
4 months ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.2 Safari/605.1.15
Browser/OS:
Safari 26 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
RegEx.test
66147424.0 Ops/sec
String.includes
65053000.0 Ops/sec
String.match
37931960.0 Ops/sec
Related benchmarks:
Unnecessary non-capturing groups
regex .replace() vs literal .replaceAll()
IndexOf vs Includes vs Reg StartsWith vs Reg Includes in string
Javascript: Case insensitive string comparison performance 3
Array from vs string split with large strings
String.replace(RegEx) vs String.replaceAll(String)
replaceAll vs regex replace pt2
replaceAll vs regex replace pt3
RegEx.test vs. String.includes vs. String.match vs String.indexOf - Long String
Comments
Confirm delete:
Do you really want to delete benchmark?