My regular expression must meet the following:
- It must have a minimum of 8 characters,
- minimum 2 capital letters,
- minimum 2 lowercase letters
- and minimum 2 numeric characters.
Searching the internet I have found this one that is similar to mine, which is to validate with at least one digit, at least one lowercase letter and at least one uppercase:
^(?=\w*\d)(?=\w*[A-Z])(?=\w*[a-z])\S{8,16}$
It would be something like this:
?=
With the (look ahead) operator you check that:(?:.*\d){2}
(?:.*[A-Z]){2}
(?:.*[a-z]){2}
With the quantifier
{8,}
you indicate that it must have a minimum length of 8 with no maximum limit.