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
| Token | Explanation |
|---|---|
| ^ | Start of string |
| [a-zA-Z0-9]+ | One or more letters or digits |
| $ | End of string |
Test Examples
| Input | Match? |
|---|---|
| Hello123 | Match |
| ABC | Match |
| hello world | No match |
| special!char | No match |
Common Use Cases
- Input sanitization
- Token validation
- ID format checking
Variations
^[a-zA-Z0-9\s]+$Allows spaces
^[\w]+$Includes underscores
Other Regex Patterns
Want to test this pattern with your own data?
Open the Regex Tester