I need the user input to:
- have no numbers
- be 4 characters long
- only use certain letters of the alphabet [R, B, G, P, Y, O]
I have figured out how to do no numbers and only 4 character length, however, I can't seem to figure out how to restrict certain letters of the alphabet (everything other than R, B, G, P, Y, O.)
guess = input.nextLine();
guess = guess.toUpperCase();
while (guess.length() != 4 || guess.contains("[0-9]") || guess.contains("[ACDEFHIJKLMNQSTUVWXZ]")) {
System.out.println("Bad input! Try again");
System.out.println("Use the form \"BGRY\"");
guess = input.nextLine();
}
This is the code I have so far, it doesn't seem to work