String is alphanumeric

JavaScript, String, Regexp · Oct 20, 2020

Checks if a string contains only alphanumeric characters.

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

More like this

  • String is alpha

    Checks if a string contains only alpha characters.

    JavaScript, String · Dec 31, 2020

  • String is anagram

    Checks if a string is an anagram of another string (case-insensitive, ignores spaces, punctuation and special characters).

    JavaScript, String · Oct 20, 2020

  • Check if string contains whitespace

    Checks if the given string contains any whitespace characters.

    JavaScript, String · Oct 18, 2020