find all alphabet between capital A to capital Z


import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class MatchChar {
public static void main(String[] args) {
String pattern="[A-Z]";

String text="5 a T u 1 2 U";

Pattern p=Pattern.compile(pattern);
    
String tt[]=text.split("\\s");
 
for(int i=0; i < tt.length ; i++){
Matcher m=p.matcher(tt[i]);
System.out.println(m.matches()+"\t"+tt[i]);
}
}
}

Output is:-

false 5
false a
true T
false u
false 1
false 2

true U


No comments: