Reputation: 6697
Here is my pattern:
^(?=.*[a-z])(?=.*[A-Z]).+$
It's a password validation. As you know:
^
Matches the start of the string
(?=.*[a-z])
checks if somewhere in the string is a lowercase character
(?=.*[A-Z])
checks if somewhere in the string is a uppercase character
Now I need to add some count conditions to the pattern. I mean, I need to count:
{6,}
, but I don't know how should I use it)How can I do that?
Upvotes: 0
Views: 66
Reputation: 559
Try this:
^(?=.*[a-z])(?=(.*[A-Z]){3,}).{6,}$
You can check here
Upvotes: -1
Reputation: 8413
Quantifiers are key here. You can use {6,}
for your matching pattern for the first conditions and expand your second lookahead a bit for your second condition, like
^(?=.*[a-z])(?=(?:[^A-Z]*[A-Z]){3}).{6,}$
See https://regex101.com/r/DjSqbr/1
Note: I have extended [^A-Z]
to [^A-Z\r\n]
to work properly with multline strings.
Upvotes: 2