Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
how fast is regex?
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Linux; Android 9; VTR-L09 Build/HUAWEIVTR-L09; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/85.0.4183.101 Mobile Safari/537.36
Browser:
Chrome Mobile 85
Operating system:
Android
Device Platform:
Mobile
Date tested:
9 months ago
use existing regex
1.1M/s
instantiate new regex
1.1M/s
View exact numbers
Test name
Executions per second
✓
use existing regex
1,102,663 Ops/sec
instantiate new regex
1,063,701 Ops/sec
Script Preparation code:
const prepared = /[.*+?^${}()|[\]\\]/g;
Tests:
instantiate new regex
const blah = "whatever" const r = blah.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")
use existing regex
const blah = "whatever" const r = blah.replace(prepared, "\\$&")