Regular Expressions Password validation regex A password containing at least 2 uppercase, 1 lowercase, 2 digits and is of length of at least 10


Example

This can be done with a bit of modification in the above regex

 ^(?=.{10,}$)(?=(?:.*?[A-Z]){2})(?=.*?[a-z])(?=(?:.*?[0-9]){2}).*$

or

 ^(?=.{10,}$)(?=(?:.*[A-Z]){2})(?=.*[a-z])(?=(?:.*[0-9]){2}).*

Let's see how a simple regex ^(?=(?:.*?[A-Z]){2}) works on string abcAdefD

enter image description here

Image Credit :- https://regex101.com/