![java判断字符串String中是否存在中文 java判断字符串String中是否存在中文](https://image.shishitao.com:8440/aHR0cHM6Ly9ia3FzaW1nLmlrYWZhbi5jb20vdXBsb2FkL2NoYXRncHQtcy5wbmc%2FIQ%3D%3D.png?!?w=700&webp=1)
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"));
}
}