Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
regex vs double replace vs substring
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Mobile Safari/537.36
Browser:
Chrome Mobile 144
Operating system:
Android
Device Platform:
Mobile
Date tested:
5 months ago
substring
6.5M/s
double replace
4.2M/s
regex
3.6M/s
View exact numbers
Test name
Executions per second
✓
substring
6,493,520 Ops/sec
double replace
4,179,820 Ops/sec
regex
3,620,926 Ops/sec
Script Preparation code:
var testStr = '[marketCode::US]'; var outputStr = '';
Tests:
regex
outputStr = testStr.replace(/[\[\]]/g, '');
double replace
outputStr = testStr.replace('[', '').replace(']', '');
substring
outputStr = testStr.substring(1, testStr.length - 1);