判断是不是字母: Character.isLetter(ch[i])
import java.util.regex.*;
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String test = sc.nextLine();
char[] ch = test.toCharArray();
StringBuffer sb = new StringBuffer();
for (int i = 0; i < ch.length; i++) {
if (Character.isLetter(ch[i])) {
sb.append(ch[i]);
}else{
sb.append(" ");
}
}
String[] arr = sb.toString().split(" ");
for (int i = arr.length - 1; i >= 0; i--) {
System.out.print(arr[i]+" ");
}
}
}