← Back to all regex patterns
Validation
Low backtracking risk

Regex for Strong Password

This pattern enforces a minimum length plus lower, upper, digit, and symbol presence. It is useful for UI hints, but real password policy should still be enforced server-side.

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

Try this pattern

Matches current input
Tr0ub4dor&3!

1 match found in the current text.

Passing examples

  • Tr0ub4dor&3!
  • A-Longer9#Pass

Failing examples

  • short1A!
  • alllowercase123!

Code examples

JavaScript
const regex = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[^A-Za-z\d]).{12,}$/g;
regex.test(input);
Python
import re
pattern = re.compile(r"^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[^A-Za-z\d]).{12,}$")
bool(pattern.search(input))
Go
re := regexp.MustCompile("^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)(?=.*[^A-Za-z\\d]).{12,}$")
matched := re.MatchString(input)

Related Validation Patterns