Regex for a Strong Password (Upper, Lower, Digit, 8+ Chars)
Uses lookaheads to require at least one lowercase letter, one uppercase letter, and one digit, with a minimum length.
Published October 11, 2026
Uses lookaheads to require at least one lowercase letter, one uppercase letter, and one digit, with a minimum length.
Key points
- Each (?=...) is a lookahead that checks a condition without consuming characters, letting multiple independent requirements combine in one pattern
- Add another lookahead like (?=.*[!@#$%^&*]) to also require a special character
Example
^(?=.*[a-z])(?=.*[A-Z])(?=.*\d).{8,}$