Q:

Why this regular expresion doesn't accept when I write the conditions in sequence?

I want to write a regular expression for a password with these conditions:
1- The password must contains 4 letters at least.
2- The password must contains 2 digits.
3- The password must contains 2 punctuation symbols.
4- The password must have a minimum length of 8 characters.
This is the regular expresion that I have: "^((?=.*?\\p{L}.{4,})(?=.*?\\p{N}.{2,})(?=.*?\\p{P}.{2,})).{8,}$"
And my problem is that yhis expresion doesn't accept this as password an I don't know why: "abcd12.-".
Can anyone help me with this problem? 
Thank you 

A:

This part in the expressions (?=.*?\\p{L}.{4,} checks if there is a letter followed by 4 or more times any character.
You could update your expression to use non capturing groups (?: and repeat the groups n times matching a letter, a number or punctuation instead.
 ^(?=(?:.*\\p{L}){4})(?=(?:.*\\p{N}){2})(?=(?:.*\\p{P}){2}).{8,}$

Regex demo
Note that using .{8,} matches at least 8 times any character except a newline, also matching spaces.

