Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Number matching
Take a string and match only the numbers
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:133.0) Gecko/20100101 Firefox/133.0
Browser:
Firefox 133
Operating system:
Mac OS X 10.15
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
String.prototype.match
3393988.2 Ops/sec
String.prototype.split filter
1194901.1 Ops/sec
String.prototype.matchAll
625083.4 Ops/sec
HTML Preparation code:
<div></div>
Script Preparation code:
const text = 'hello1hello2hello3hello4hello5hello6hello78hello9_0'
Tests:
String.prototype.match
const numbers = [...text.match(/\d+/g)].map(n => +n)
String.prototype.split filter
const numbers = text.split('').map(n => +n).filter(Number)
String.prototype.matchAll
const numbers = [...text.matchAll(/\d+/g)].map(n => +n)