Strong PasswordRegex — Pattern, Examples & Code
^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?]).{8,}$What it matches / doesn't match
| Matches ✅ | Does not match ❌ |
|---|---|
●Secure@123 | ●password |
●P@ssw0rd! | ●PASSWORD1 |
●MyStr0ng#Pass | ●Short1! |
How it works
Uses four lookaheads to require at least one lowercase letter, one uppercase letter, one digit, and one special character from a common set. The final .{8,} enforces a minimum length of 8 characters. Adjust the special character class or minimum length to match your security policy.
Code Usage
JavaScript
const regex = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[!@#$%^&*()_+\-=]).{8,}$/;
regex.test("Secure@123"); // truePython
import re
pattern = re.compile(r'^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[!@#$%^&*()_+\-=]).{8,}$')
bool(pattern.match("Secure@123")) # TrueGo
import "regexp" // Go RE2 does not support lookaheads — validate each rule separately: r1 := regexp.MustCompile(`[a-z]`) r2 := regexp.MustCompile(`[A-Z]`) r3 := regexp.MustCompile(`\d`) r4 := regexp.MustCompile(`[!@#$%^&*]`) valid := len(pw) >= 8 && r1.MatchString(pw) && r2.MatchString(pw) && r3.MatchString(pw) && r4.MatchString(pw)
Need a custom regex for a different use case?
Generate a custom regex with AI →FAQ
What does the Strong Password regex pattern match?
Uses four lookaheads to require at least one lowercase letter, one uppercase letter, one digit, and one special character from a common set. The final .{8,} enforces a minimum length of 8 characters. Adjust the special character class or minimum length to match your security policy.
How do I use the Strong Password regex in JavaScript?
const regex = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[!@#$%^&*()_+\-=]).{8,}$/; regex.test("Secure@123"); // true
Can I use the Strong Password regex in Python?
Yes. import re pattern = re.compile(r'^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[!@#$%^&*()_+\-=]).{8,}$') bool(pattern.match("Secure@123")) # True
