Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
String.matchAll() vs RegExp.exec()
(version: 1)
Comparing performance of:
String.matchAll() vs RegExp.exec()
Created:
4 months ago
by:
Guest
Go to the latest result
HTML Preparation code:
<!--your preparation HTML code goes here-->
Script Preparation code:
const regex = new RegExp('[A-Z $%*+\\-./:]+', 'g') const string = 'Hello world, this is a just wonderful day!'
Tests:
String.matchAll()
const results = [] for (const result of string.matchAll(regex)) { results.push(result) }
RegExp.exec()
const results = [] let result while ((result = regex.exec(string)) !== null) { results.push(result) }
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
String.matchAll()
RegExp.exec()
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/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36
Browser/OS:
Chrome 145 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
RegExp.exec()
5.4M/s
String.matchAll()
3.9M/s
View exact numbers
Test name
Executions per second
✓
RegExp.exec()
5,446,756 Ops/sec
String.matchAll()
3,864,937 Ops/sec
Related benchmarks
Define Regex inline vs not inline...
match vs exec with many matches
Regex vs Forloop Performance
regexp.matchAll vs regexp.exec
Is it worth checking for empty string before replace with regex?
Comments
Confirm delete:
Do you really want to delete benchmark?