c
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);
}