I need a regex to test a users password for the following:
Must be minimum 8 characters with alphanumeric format, no more than 4 consecutive numbers, no id in the password (i.e. cannot use: 1234, 9876, abcd, or 1234abvc)
I am using ^([a-zA-Z0-9!@#$*%]{8,15})$ currently and it works great, but doesn’t account for the consecutive characters piece. I’m not sure how to add that to the mix.
Any help would be great!
If you want to solve it with regex, just add an negative lookahead assertion. You can test it here
The added part
(?!.*\d{4,}.*)does not consume your string, it just checks if there are 4 or more numbers in a row and if so, its false.Why do you want to limit the passwords to 15 characters? I removed this in my example.