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:
4 months ago
Test name
Executions per second
regex
3620926.0 Ops/sec
double replace
4179819.5 Ops/sec
substring
6493520.5 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);