How to know that string contains at least 2 upper case letters? For example these are valid strings "Lazy Cat", "NOt very lazy cat". Working with Java 1.7.
Try with following regex:
"^(.*?[A-Z]){2,}.*$"
or
"^(.*?[A-Z]){2,}"
This regex works.
string.matches(".*[A-Z].*[A-Z].*")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With