Alphanumeric Only in PY
Match strings containing only letters (A–Z, a–z) and digits (0–9), with no spaces or special characters.
Try it in the PY tester →Pattern
regexPY
^[a-zA-Z0-9]+$Python (re) code
pyPython
import re
pattern = re.compile(r"^[a-zA-Z0-9]+$")
input_text = "Hello123"
for m in pattern.finditer(input_text):
print(m.group(0))Stdlib `re` module — no third-party dependency. Works on Python 3.6+.
How the pattern 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
—