-1

My password strength criteria is as below :

  • Character length: 8 -> 24
  • Contains least 3 of following types:
    • Uppercase letter [A-Z]
    • Lowercase letter [a-z]
    • Numeric [0-9]
    • Special character ~`!@#$%^&*()-_=+[{]}\|;:'"<,>.?/

Can anyone help me to make regular expression and explain. Thanks.

Leo Vo
  • 9,980
  • 9
  • 56
  • 78

2 Answers2

0

It would be very difficult to do in one regex. Personally, I'd check for each case separately and count if you've got three matches. It would be easier to read and maintain.

So match [A-Z] then [a-z] then [0-9] and finally [~`!@#$%^&*()-_=+[{]}\|;:'"<,>.?/]

If you end up with a match in three of the tests that's success.

user489998
  • 4,473
  • 2
  • 29
  • 35
0

Use this Regex:

(?=.{8,24})(?=.*\d)(?=.*[A-Za-z])(?=.*[~`!@#\$%\^&\*()_=\+[{\]}\|;:'"<,>\.\?/]).*

Regular expression visualization

Debuggex Demo

Amit Joki
  • 58,320
  • 7
  • 77
  • 95