判断字符串是否包含汉字

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Test2 {

final static Pattern p = Pattern.compile("[\u4e00-\u9fa5]");


public static void main(String[] args) {


boolean x = isContainChinese("s你好ss");
System.out.println(x);


}


public static boolean isContainChinese(String str) {
Matcher m = p.matcher(str);
if (m.find()) {
return true;
}
return false;
}
}
posted @ 2018-03-14 19:08  范世强  阅读(625)  评论(0编辑  收藏  举报