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:
one month ago
by:
Guest
Jump 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:
one month 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
Test name
Executions per second
String.matchAll()
3864936.8 Ops/sec
RegExp.exec()
5446755.5 Ops/sec
Related benchmarks:
Define Regex inline vs not inline...
Test checker
match vs exec with many matches
String.match 4
Re-usable regex
Regex vs Forloop Performance
RegEx.test vs. String.includes vs. for
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?