Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
string replaceAll test
(version: 0)
Comparing performance of:
split and join vs regex replace
Created:
5 years ago
by:
Guest
Jump to the latest result
Script Preparation code:
function escapeRegExp(string) { return string.replace(/[.*+\-?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string } function replaceAll(str, find, replace) { return str.replace(new RegExp(escapeRegExp(find), 'g'), replace); } str = "Test abc test test abc test...Test abc test test abc test...Test abc test test abc test...Test abc test test abc test...Test abc test test abc test..."
Tests:
split and join
str.split("abc").join("def")
regex replace
replaceAll(str, 'abc', 'def')
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
split and join
regex replace
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:
Wildcard Match Test
Global regex replace vs replaceAll
sa sad test
replaceAll str vs regex
Comments
Confirm delete:
Do you really want to delete benchmark?