Skip to main content
CalcHive

Regex for Alphanumeric String

Matches strings containing only letters (upper and lowercase) and digits. No spaces or special characters.

Pattern

/^[a-zA-Z0-9]+$/

Pattern Breakdown

TokenExplanation
^Start of string
[a-zA-Z0-9]+One or more letters or digits
$End of string

Test Examples

InputMatch?
Hello123Match
ABCMatch
hello worldNo match
special!charNo match

Common Use Cases

  • Input sanitization
  • Token validation
  • ID format checking

Variations

^[a-zA-Z0-9\s]+$

Allows spaces

^[\w]+$

Includes underscores

Want to test this pattern with your own data?

Open the Regex Tester