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
Image Credit :- https://regex101.com/