{image}
java怎么识别一个字符串中有汉字
可以使用正则表达式+中文字符编码区间验证一个字符串旁州中是否包含汉字
代码如下:
public static void main(String[] args) {
int count = 0;
String regEx = "[\\u4e00-\\腊启没u9fa5]";
//(regEx);
String str = "中文fdas ";
//(str);
Pattern p = (regEx);
Matcher m = (str);
while (()) {
for (int i = 0; i <= t(); i++) {
count = count + 1;
}
}
("共有 " + count + "轮纳个 ");
}