\uxxxx
其中xxxx表示一个16进制数字 这种格式是unicode码的写法表示一个char字符
\u0022表示第34号的unicode字符 " 双引号
这个是unicode编码 把字符转为unicode码
public static void judgeChineseCharactor(String str){
String regEx = "[\u4e00-\u9fa5]";
// 判断是否存在中文字符
if(str.getBytes().length == str.length()){
System.out.println("无汉字");
}else{
// 如果存在中文字符,找出字符串中的中文字符
Pattern p = Pattern.compile(regEx);
Matcher m = p.matcher(str);
while(m.find()){
System.out.print(m.group()+"");
}
}
}
public static void main(String[] args) {
judgeChineseCharactor("hello,world");
judgeChineseCharactor("hello, 世界!");
}