T
ToolPrime

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

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.

Related Tools