public static void main(String[] args) {String str = "测 试 WG23-D";// 只留字母String s1 = str.replaceAll("[^a-zA-Z]", "");// 只留数字String s2 = str.replaceAll("[^0-9]", "");// 只留中文String s3 = str.replaceAll("[^\u4e00-\u9fa5]", "");System.out.println("s1 = " + s1);System.out.println("s2 = " + s2);System.out.println("s3 = " + s3);}