Regex for Strong Password
Validates strong passwords: min 8 chars, uppercase, lowercase, digit, special char.
Pattern
/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$/ Live Tester
Enter a string to test
Examples
✓ MyP@ss1word
✓ Str0ng!Pass
✓ Ab1!defgh
✗ password
✗ PASSWORD1!
✗ Short1!
Pattern Breakdown
(?=.*[a-z]) — at least one lowercase
(?=.*[A-Z]) — at least one uppercase
(?=.*\d) — at least one digit
(?=.*[@$!%*?&]) — at least one special character
[A-Za-z\d@$!%*?&]{8,}$ — minimum 8 characters
Code Snippets
Javascript
const regex = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$/;
regex.test("MyP@ss1word"); // true Python
import re
pattern = r"^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$"
bool(re.match(pattern, "MyP@ss1word")) # True Php
$pattern = '/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$/';
preg_match($pattern, "MyP@ss1word"); // 1 Related Patterns
Email Address /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/ URL /^https?:\/\/(www\.)?[a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([a-zA-Z0-9()@:%_+.~#?&/=-]*)$/ Phone Number (International) /^\+?[1-9]\d{1,14}$/ Phone Number (US) /^\(?[2-9]\d{2}\)?[-.\s]?\d{3}[-.\s]?\d{4}$/ Phone Number (EU) /^\+?[1-9][0-9]{0,3}[\s.-]?\(?[0-9]{1,5}\)?[\s.-]?[0-9]{1,5}[\s.-]?[0-9]{1,5}$/ IPv4 Address /^((25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(25[0-5]|2[0-4]\d|[01]?\d\d?)$/
Frequently Asked Questions
What is the regex for Strong Password?▾
The regex pattern for Strong Password is /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$/. Validates strong passwords: min 8 chars, uppercase, lowercase, digit, special char.
How do I use the Strong Password regex in JavaScript?▾
In JavaScript you create the pattern with a regex literal or the RegExp constructor and call .test() to check a string against it. A ready-to-copy example is shown in the Code Snippets section above, alongside Python and PHP versions.
What does the Strong Password pattern match?▾
It matches strings like MyP@ss1word; it rejects strings like password. See the Examples section above for the full list of matching and non-matching cases.