recently they sent me an exercise to check a password with regular expressions, which would have to have a capital letter, lower case letters, and two numbers, since I have no experience with regex I created a class to experiment with, what happened was that I found the solution, but for separate expressions and coincidentally joining them in a single expression returns false. Could someone please help me with this? `
public class main {
public static void main(String[] args) {
String cadena="12Aaniel";
//return true 8 characters minimum
System.out.println("ejemplo10: "+cadena.matches(".{8,}"));
//return true has at least one capital letter
System.out.println("ejemplo10: "+cadena.matches("(.*[A-Z]+.*)"));
//return true has at least 2 numbers
System.out.println("ejemplo10: "+cadena.matches("(.*[0-9]{2,}.*)"));
//return false all together
System.out.println("ejemplo10: "+cadena.matches(".{8,}(.*[A-Z]+.*)(.*[0-9]{2,}.*)"));
}
}
`
I need all in one expresion