package zwb.tools;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* @author zwb
*
*/
public class isHaveHanZi {
public static boolean isHaveHanZi(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 = count + 1;
}
}
if(count==0){
flag=false;
}
return flag;
}
public static void main(String[] args) {
System.out.println(isHaveHanZi("12张"));
}
}
java判断string字符串中是否存在汉字
最新推荐文章于 2022-12-12 15:54:16 发布