Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Unnecessary non-capturing groups
(version: 0)
https://stackoverflow.com/questions/45291700/javascript-regex-non-capture-faster-than-no-parenthesis-at-all
Comparing performance of:
unneededNonCaptureRE vs noNonCaptureRE vs anotherUnneededNonCapture vs anotherNoNonCapture vs indexOf
Created:
8 years ago
by:
Guest
Jump to the latest result
Script Preparation code:
var loremString = "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."
Tests:
unneededNonCaptureRE
/(?:z)+/.exec(loremString)
noNonCaptureRE
/z+/.exec(loremString)
anotherUnneededNonCapture
/lab(?:o)rum/.exec(loremString)
anotherNoNonCapture
/laborum/.exec(loremString)
indexOf
loremString.indexOf('laborum')
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (5)
Previous results
Fork
Test case name
Result
unneededNonCaptureRE
noNonCaptureRE
anotherUnneededNonCapture
anotherNoNonCapture
indexOf
Fastest:
N/A
Slowest:
N/A
Latest run results:
No previous run results
This benchmark does not have any results yet. Be the first one
to run it!
Related benchmarks:
Unnecessary non-capturing groups
Unnecessary non-capturing groups
Unnecessary non-capturing groups
String.replace(RegEx) vs String.replaceAll(String)
Comments
Confirm delete:
Do you really want to delete benchmark?