find all alphabet between a to z in any case


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

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

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

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
true a
true T
true u
false 1
false 2
true U

true p


No comments: