Categories
Web Development

Regex for Alphanumeric Only – No Spaces, dashes or Underlines

Regex for A-Z, 0-9 and limited to 0-32 characters

Pattern:

/^[a-zA-Z0-9]{0,32}$/

Usage

if (preg_match('/^[a-zA-Z0-9]{0,32}$/', $mystring))
{
    return true;
}

 

Leave a Reply