In Java, is there a way to find out if string contains multiple letters/characters using Regular Expressions/ Pattern matching?
I have tried to solve my problem using below code
String id = "A12B45";
Pattern pattern = Pattern.compile("[A-Z]*");
Matcher matcher = pattern.matcher(id);
if (matcher.find())
{
System.out.println("YES---");
} else
{
System.out.println("NO---");
}
The above code is not giving me an output which I want. When string contains more than one alphabet letter then it should return "YES---". Can you please help?
YES---when the string contains more than one letter consecutively? For exampleAK12B45should printYES---(because it contains A followed immediately by K) butA12B45should printNO---?