Python (re)

Password (No Special Chars) in PY

Validate passwords requiring at least one lowercase, one uppercase, one digit, and minimum 8 characters — no special characters required.

Try it in the PY tester →

Pattern

regexPY
^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[A-Za-z\d]{8,}$

Python (re) code

pyPython
import re

pattern = re.compile(r"^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[A-Za-z\d]{8,}$")
input_text = "Password1"
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

Three positive lookaheads (?=.*[a-z]) (?=.*[A-Z]) (?=.*\d) require a lowercase letter, uppercase letter, and digit somewhere in the string. [A-Za-z\d]{8,}$ then matches 8+ alphanumerics. Lookaheads are zero-width so they don't consume — they're constraints, not consumers. Note: Go's RE2 does not support lookaheads, so this pattern won't compile there.

Examples

Input

Password1

Matches

  • Password1

Input

MyPass99

Matches

  • MyPass99

Input

weakpass

No match

Same pattern, other engines

← Back to Password (No Special Chars) overview (all engines)