DevKits

Validation

Validate a strong password

Enforce password rules: min length + upper + lower + digit + symbol.

Pattern

Regular expression

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

How it works

Uses four look-aheads to require at least one lowercase, one uppercase, one digit, and one special character; then anchors to `.{8,}` for minimum length. Adjust the minimum length as needed.

Matches

  • Pa$$w0rd!
  • Strong1@X
  • aB1@aaaa

Non-matches

  • short1A!
  • alllowercase1!
  • NOLOWER1!

Common gotchas

Rigid password rules make weak, guessable passwords. Modern guidance (NIST 800-63B) prefers long passphrases with breached-password checks over complexity rules. Consider `zxcvbn` for real strength estimation.

Language snippets

JavaScript

const re = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[^A-Za-z0-9]).{8,}$/;

Python

re.match(r"^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[^A-Za-z0-9]).{8,}$", password)

Go

// Go regexp doesn't support look-aheads — validate with multiple simpler checks or use github.com/dlclark/regexp2

Java

Pattern.compile("^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)(?=.*[^A-Za-z0-9]).{8,}$")

Related patterns

Try any pattern live in the Regex Tester