Regular Expressions 101

Community Patterns

Community Library Entry

1

Regular Expression
PCRE2 (PHP >=7.3)

/
^(?=(.*[A-Z]){1})(?=(.*[a-z]){1})(?=(.*[0-9]){1})(?=(.*[@#$%^!&+=.\-_*]){2})([a-zA-Z0-9@#$%^!&+=*.\-_]){8,}$
/

Description

This regular expression allows you to simply check if a password matches with your conditions. By default it will require:

  • 1 {1} uppercase letter [A-Z] or more
  • 1 {1} lowercase letter [a-z] or more
  • 1 {1} number [0-9] or more
  • 1 {1} special character [@#$%^!&+=.\-_*] or more You can easily change the minimum by editing the value in the respective {1}
Submitted by Pythack - 4 years ago (Last modified 3 years ago)