String str = "adsf adS
DFASFSADF阿德斯防守对方asdfsadf37《?:?@%#¥%#¥%@#$%#@$%^><?1234";
str = str.replaceAll("[^a-zA-Z0-9]", "");
2.提取字符串中所有的英文
str = str.replaceAll("[^a-zA-Z0-9]", "");
System.out.println(str);
1.判断字符串中是否全为英文
-
boolean result = str.matches( "[a-zA-Z]+"); //true:全文英文
-
str.matches( "[a-zA-Z0-9]+") //判断英文和数字
2.提取字符串中所有的英文
-
str = str.replaceAll( "[^a-z^A-Z]", "");
-
//"[^a-z^A-Z]"改为"[^a-z^A-Z^0-9]"即获取所有的英文和数字
3.判断字符串中是否含英文
-
String regex = ".*[a-zA-z].*";
-
str.matches(regex); //true:含有英文