public static void main(String[] args) { boolean s = isContainChinese("4"); System.out.println(s); } /** * 字符串是否包含中文 * * @param str 待校验字符串 * @return true 包含中文字符 false 不包含中文字符 */ public static boolean isContainChinese(String str) { Pattern p = Pattern.compile("[\u4E00-\u9FA5|\\!|\\,|\\。|\\(|\\)|\\《|\\》|\\“|\\”|\\?|\\:|\\;|\\【|\\】]"); Matcher m = p.matcher(str); if (m.find()) { return true; } return false; }
06-13
2179
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交