I am trying to do a simple Regex in Java and it's failing for some reason. All I want to do is, validate whether a string contains upper case letters and/or numbers. So ABC1, 111 and ABC would be valid but abC1 would not be.
So I tried to do this:
if (!e.getId().matches("[A-Z0-9]")) {
throw new ValidationException(validationMessage);
}
I made sure that e.getId() has ABC1 but it still throws the exception. I know it's something really small and silly but i'm unable to figure it out.