-8

I have following requirement in my application. I need to maintain password complexity in my application as mention below.

password length is minimum 8 characters, a capital letter, a special character apart from @ and numeric values which are not in sequence

Can anyone help me in getting regular expression for the above criteira or else C# code is also helpful for me.

Dmitry
  • 13,797
  • 6
  • 32
  • 48

1 Answers1

5

Let me suggest a different approach: Instead of creating a fancy regular expression that confuses everyone reading it (including you, since you cannot come up with one on your own), just encode the logic in a few simple C# statements:

if (mypassword.Length < 8)
    myerror = "The password must have a minimum length of 8 characters.";
else if (!Regex.IsMatch(mypassword, "[A-Z]"))
    myerror = "The password must contain at least one capital letter.";
...
Heinzi
  • 167,459
  • 57
  • 363
  • 519