How the pattern works
| Part | Meaning |
|---|---|
^[A-Za-z0-9]+$ | One or more ASCII letters or digits, and nothing else — no spaces, underscores or symbols |
Code examples
JavaScript
const re = /^[A-Za-z0-9]+$/;
re.test(value); // true or falsePython
import re
bool(re.fullmatch(r'[A-Za-z0-9]+', value))PHP
preg_match('/^[A-Za-z0-9]+$/', $value) === 1;
Notes and limitations
Add _ or - inside the brackets to allow them; \w is a shortcut for [A-Za-z0-9_].
Regex TesterType a pattern and watch matches highlight live in your test text.
Open the tool Frequently asked questions
What is the regex for alphanumeric?
/^[A-Za-z0-9]+$/ — it matches the whole string. See the table above for what each part does.
Which examples match?
Of the examples tested, these match: abc123, ABC, 2026. The others don’t.
How do I test this regex?
Click “Open in Regex Tester” — the pattern, flags and sample text load automatically, and matches highlight as you edit.