Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Alphanumeric String (regex, charCodeAt, [])
Check if a string only contains alpha-numeric characters.
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:138.0) Gecko/20100101 Firefox/138.0
Browser:
Firefox 138
Operating system:
Windows
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
Regex
17147212.0 Ops/sec
charCodeAt
11361514.0 Ops/sec
[]
39542964.0 Ops/sec
HTML Preparation code:
var string = "isAlphaNumeric091";
Script Preparation code:
var string = "isAlphaNumeric091";
Tests:
Regex
/^[a-z0-9]+$/i.test(string)
charCodeAt
function isAlphaNumeric(str) { for (let i = 0; i < str.length; i++) { let code = str.charCodeAt(i) if (!(code > 47 && code < 58) && // numeric (0-9) !(code > 64 && code < 91) && // upper alpha (A-Z) !(code > 96 && code < 123)) { // lower alpha (a-z) return false } } return true } isAlphaNumeric(string)
[]
function isAlphaNumeric(str) { for (let i = 0; i < str.length; i++) { const code = str[i] if (!(code > 47 && code < 58) && // numeric (0-9) !(code > 64 && code < 91) && // upper alpha (A-Z) !(code > 96 && code < 123)) { // lower alpha (a-z) return false } } return true } isAlphaNumeric(string)