Regular Expressions 101

Community Patterns

Community Library Entry

0

Regular Expression
PCRE (PHP <7.3)

/
\A(?=.*[A-Z].*[A-Z])(?=.*[a-z].*[a-z])(?=.*[0-9].*[0-9])(?=.*[^a-zA-Z0-9].*[^a-zA-Z0-9])
/
i

Description

Checks password for following attributes:

  • At least 2 uppercase letters
  • At least 2 lowercase letters
  • At least 2 numbers
  • At least 2 non-alphanumeric characters

Length is deliberately not checked as it's best to pre-check using standard coding.

Submitted by Visigral - 10 years ago