Files
30-seconds-of-code/snippets/is-alpha-numeric.md
Angelos Chalaris 61200d90c4 Kebab file names
2023-04-27 21:58:35 +03:00

593 B

title, tags, cover, firstSeen, lastUpdated
title tags cover firstSeen lastUpdated
String is alphanumeric string,regexp mountain-lake-cottage-2 2020-09-06T07:59:16+03:00 2020-10-20T23:02:01+03:00

Checks if a string contains only alphanumeric characters.

  • Use RegExp.prototype.test() to check if the input string matches against the alphanumeric regexp pattern.
const isAlphaNumeric = str => /^[a-z0-9]+$/gi.test(str);
isAlphaNumeric('hello123'); // true
isAlphaNumeric('123'); // true
isAlphaNumeric('hello 123'); // false (space character is not alphanumeric)
isAlphaNumeric('#$hello'); // false