I have written a regular expression which could potentially be used for password strength validation:
^(?:([A-Z])*([a-z])*(\d)*(\W)*){8,12}$
The expression consists of four groups:
- Zero or more uppercase characters
- Zero or more lowercase characters
- Zero or more decimal digits
- Zero or more non-word characters (!, £, $, %, etc.)
The way I want it to work is to determine how many of the groups have been matched in order to determine the strength of the password. so for example, if only 1 group is matched, it would be weak. If all four groups were matched, it would be strong.
I have tested the expression using Rubular (a Ruby regular expression editor).
Here I can see visually, how many groups are matched, but I want to do this in JavaScript. I wrote a script that returns the number of matched groups, but the results were not the same as I can see in Rubular.
How can I achieve this in JavaScript? and is my regular expression up to the task?