JAVA判斷String中是否含有中文

/**
     * 判断String中是否包含中文
     * @param str
     * @return
     */
    public static boolean isContainChinese(String str) {
 
        Pattern p = Pattern.compile("[\u4e00-\u9fa5]");
        Matcher m = p.matcher(str);
        if (m.find()) {
            return true;
        }
        return false;
    }
发布了130 篇原创文章 · 获赞 4 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/Iverson941112/article/details/96178525
今日推荐