java判断字符串String中是否存在中文
public class IsContainChinese {
public static boolean isContainChinese (String str){
boolean flag=true;
int count = 0;
String regEx = "[\\u4e00-\\u9fa5]";
Pattern p = Pattern.compile(regEx);
Matcher m = p.matcher(str);
while (m.find()) {
for (int i = 0; i <= m.groupCount(); i++) {
count++;
}
}
if(count==0){
flag=false;
}
return flag;
}
public static void main(String[] args) {
System.out.println(isContainChinese("我是lzhl"));
}
}