使用正则表达式解决 Java

import java.util.*;
public class Main {
        public static void main(String[] args) {
            Scanner sc = new Scanner(System.in);
            while (sc.hasNextLine()) {
                String str = sc.nextLine();
                str = str.replaceAll("[^a-zA-Z]", " ");
                String[] strArr = str.split(" ");
                for(int i = strArr.length - 1; i >= 0 ; i--) {
                    System.out.print(strArr[i] + " ");
                }
            }
        }
}