Regex for Strong Password
Validates strong passwords: minimum 8 characters, at least one uppercase, one lowercase, one digit, and one special character.
Pattern
/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$/Pattern Breakdown
| Token | Explanation |
|---|---|
| ^ | Start of string |
| (?=.*[a-z]) | Lookahead: at least one lowercase letter |
| (?=.*[A-Z]) | Lookahead: at least one uppercase letter |
| (?=.*\d) | Lookahead: at least one digit |
| (?=.*[@$!%*?&]) | Lookahead: at least one special character |
| [A-Za-z\d@$!%*?&]{8,} | 8 or more allowed characters |
| $ | End of string |
Test Examples
| Input | Match? |
|---|---|
| MyP@ssw0rd | Match |
| Str0ng!Pass | Match |
| weakpass | No match |
| NoSpecial1 | No match |
| Short1! | No match |
Common Use Cases
- Password creation validation
- Security policy enforcement
- Account registration
Variations
^.{8,}$Minimum 8 characters only (no complexity)
^(?=.*[a-z])(?=.*[A-Z])(?=.*\d).{8,}$Without special character requirement
Other Regex Patterns
Want to test this pattern with your own data?
Open the Regex Tester