Trying to get my regular expression to work for these rules:
- Total atleast 8 characters long.
- No larger than 21.
- Should contain atleast two Uppercase
- Should contain atleast two lowercase
- Should contain atleast two numbers
- Should contain atleast two of these symbols !@#$%^&*()
- All characters can be in any permutation, do not have to be in repeated sequence.
- (Added with Edit) Cannot can contain any other character not specified above.
I think this regular expression is close but does not work correctly.
/^(?=(?:\D*\d){2,}\D*$)(?=(?:[^a-z]*[a-z]){2,}[^a-z]*$)(?=(?:[^A-Z]*[A-Z]){2,}[^A-Z]*$)(?=(?:[^!@#$%^&*]*[!@#$%^&*]){2,}[^!@#$%^&*]*$)[a-zA-Z0-9!@#$%^&*]{8,21}$/