There is a line: CTyZQW9c5j2ja

It is necessary to check if there are 2 uppercase letters and 2 lowercase letters in it, and give the result, true or false.

Climbing php.net, I did not find this. And an example, with preg_match() cannot be compiled correctly.

PS: the letters in the string can go in any order.

  • Where is the code? Attempt to solve. - Vladimir Glinskikh
  • 3v4l.org/gCj8W - vp_arth

1 answer 1

you can use positive lookaheads (?=)

 (?=.*([az].*?[az]))(?=.*([AZ].*?[AZ]))