62,614
社区成员
发帖
与我相关
我的任务
分享
String s = "as123";
if(s.matches("[^\u4e00-\u9fa5]*")){
System.out.println("没中文");
}else{
System.out.println("有中文");
}
String s = "你好123";
if(s.matches(".*[\u4e00-\u9fa5].*")){
//包含中文
}else{
//不包含中文
}
static boolean checkChinese(String name)
{
for (int i = 0; i < name.length(); i++)
{
String c = "" + name.charAt(i);
if (c.getBytes().length == 2)
{
return true;
}
}
return false;
}