boolean containsChinese = Pattern.matches(".*[\\u4e00-\\u9fa5].*", names);
if (containsChinese) {
names = names.replaceAll("[^\\u4E00-\\u9FA5]", "");
names = names.replaceAll("\\s{1,}", "");
} else {
names = names.replaceAll("[^a-zA-Z]", "");
names = names.replaceAll("\\s{1,}", "");
}
排除 中文英文 () () 以外的特殊字符
boolean containsChinese = Pattern.matches(".*[\\u4e00-\\u9fa5].*", names);
if (containsChinese) {
names = names.replaceAll("[^(\\u4E00-\\u9FA5)(())]", "");
names = names.replaceAll("\\s{1,}", "");
} else {
names = names.replaceAll("[^(a-zA-Z)(())]", "");
names = names.replaceAll("\\s{1,}", "");
}