Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
regex vs js - not Alphanumeric String
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:120.0) Gecko/20100101 Firefox/120.0
Browser:
Firefox 120
Operating system:
Windows
Device Platform:
Desktop
Date tested:
2 years ago
Test name
Executions per second
Regex
5713485.0 Ops/sec
charCodeAt
5159164.5 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)