Regular Expressions 101

Community Patterns

1...34567...585

Password policy (password requires three out of the four character types)

0

Regular Expression
PCRE (PHP <7.3)

/
((?=.*\d)(?=.*[a-z])(?=.*[A-Z])|(?=.*\d)(?=.*[a-zA-Z])(?=.*[!@#$%\^&\*\_\-+=\?|\/\(\)\\{}\[\]:<>,\.;])|(?=.*[a-z])(?=.*[A-Z])(?=.*[!@#$%\^&\*\_\-+=\?|\/\(\)\\{}\[\]:<>,\.;]))(?=\S+$).{15,}
/
gm

Description

  • A password must consist of at least fifteen characters.
  • A password must contain a character from at least three of the following four sets:
    • A-Z
    • a-z
    • 0-9
    • !@#$%^&*_-+=?|/(){}[]:<>,.;
  • No whitespaces
Submitted by RGT, Mast - 2 years ago