//g
  • 100% Free
  • No Sign-Up
  • No Credit Card
  • No Free Trial
  • No Pro Tier
  • No Watermarks

Nothing is uploaded. Just open it and start.

Strong Password Regex

At least 12 characters with a lowercase letter, a capital, a digit and a symbol, each checked by a lookahead.

/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[^A-Za-z\d]).{12,}$/

Piece by piece

  1. ^the start of the text
  2. (?=followed by (lookahead, not part of the match):
  3. .*any character except a line break, repeated 0 or more times, as many as possible
  4. [a-z]one of a–z
  5. )end of followed by
  6. (?=followed by (lookahead, not part of the match):
  7. .*any character except a line break, repeated 0 or more times, as many as possible
  8. [A-Z]one of A–Z
  9. )end of followed by
  10. (?=followed by (lookahead, not part of the match):
  11. .*any character except a line break, repeated 0 or more times, as many as possible
  12. \da digit (0–9)
  13. )end of followed by
  14. (?=followed by (lookahead, not part of the match):
  15. .*any character except a line break, repeated 0 or more times, as many as possible
  16. [^A-Za-z\d]any character except A–Z, a–z, a digit (0–9)
  17. )end of followed by
  18. .{12,}any character except a line break, repeated 12 or more times, as many as possible
  19. $the end of the text

Examples

TextResult
Correct-Horse-9Matches
aB3$aB3$aB3$Matches
password1234Doesn't match
SHORT-a1Doesn't match
NoDigitsHere!!Doesn't match
nouppercase1!xxDoesn't match
  • Rules like these aren't what makes a password strong; length and not reusing it matter more. A long random passphrase beats them.

Other common patterns

Test any regular expression →

Frequently asked questions

How do I use this password rules regex in JavaScript?
Write it as /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[^A-Za-z\d]).{12,}$/ and call re.test(text). It is anchored with ^ and $, so it checks the whole text; remove them to find it inside longer text (and add the g flag to find every one). The Code view writes it out for Python, Go and PHP too.
Is it a complete validator?
No regex is the whole story. Rules like these aren't what makes a password strong; length and not reusing it matter more. A long random passphrase beats them.
Can I try it on my own text?
Yes. The tester above already holds the examples; paste your own text over them and every match is highlighted as you type. Nothing is uploaded.

Spotted a bug or have a suggestion?

Found something broken, have an idea, or just want to say thanks about any of our tools? Every message reaches a real person.