c# - Need regex for password requirements -


I need a regex to test user password for:

Less There should be no less than 8 characters alphanumeric format, no more than 4 consecutive numbers, no id in the password (i.e. it can not be used: 1234 , 9876 , < Code> abcd , or 1234abvc )

I ^ ([a-zA-Z0- 9! @ # $ *%] {815) }) $ currently and it works great, but felt There is no account for a string of string letters. I'm not sure how to add a mixture.

Any help would be great!

If you want to solve it with regex, then just add a negative lookahead assertion. You can test it

  ^ (?!. * \ D {4,}. *) ([A-zA-Z0- 9! @ # $ *%] {8, }) $   

added part (?!. * \ D {4,}. *) does not consume your string, it only checks Whether 4 or more numbers in a row and if so, its false.

Why would you like to limit the password for 15 characters? I removed it in my example.

Comments