Validation
Alphanumeric Only
Match strings containing only letters (A–Z, a–z) and digits (0–9), with no spaces or special characters.
Try it in RegexPro →Available in
Pattern
regexengine-agnostic
^[a-zA-Z0-9]+$Raw source: ^[a-zA-Z0-9]+$
How it works
^ and $ anchor to the full string. [a-zA-Z0-9]+ requires one or more characters from the combined letter and digit set. Any space, punctuation, or symbol will cause the match to fail.
Examples
Input
Hello123Matches
Hello123
Input
abcMatches
abc
Input
has spaceNo match
—Common use cases
- •Token and code validation (invite codes, promo codes)
- •Search parameter sanitization
- •Identifier format enforcement
- •Anti-injection input filtering
Related patterns
Username
ValidationValidate usernames that are 3–16 characters long and contain only letters, digits, underscores, and hyphens.
Password (No Special Chars)
ValidationValidate passwords requiring at least one lowercase, one uppercase, one digit, and minimum 8 characters — no special characters required.
Twitter / X Handle
ValidationMatch Twitter/X @handles — 1 to 15 characters of letters, digits, or underscores preceded by @.
Credit Card Number
ValidationMatch 16-digit credit card numbers with optional spaces or hyphens between groups of 4.