-1

I have to create a regular expression for a password field. The below is the criteria for the same:

  • Must be at least ten (10) characters in length
  • Must contain at least three of the following: Upper case letters, lowercase letters, numbers, and special characters (symbols or punctuation except '<' and '>' )
  • Cannot contain more than two identical characters following each other

I am new to this regular expression and need your help here.

Thanks in advance.

ProgrammingLlama
  • 36,677
  • 7
  • 67
  • 86
user473204
  • 29
  • 3

1 Answers1

-1
Regex pattern = new Regex(@"^(?!.*(.)\1\1)
(?=.*\d) //should contain at least one digit
(?=.*[a-z]) //should contain at least one lower case
(?=.*[A-Z]) //should contain at least one upper case
[0-9a-zA-Z]{10,20}$");  //should contain at least 8 characters and maximum of 20

try this one

Ninja
  • 1
  • 2
    Not sure that does the same thing. For example, this would block me for any password that doesn't contain a digit, even if I had uppercase, lowercase, and a special. – ProgrammingLlama Nov 19 '19 at 04:46
  • Thanks for looking in to this. But this is not fully satisfying my criteria. The important part which i am looking for is "Must contain at least three of the following: Upper case letters, lowercase letters, numbers, and special characters (symbols or punctuation except '<' and '>' )". – user473204 Nov 19 '19 at 04:55