码迷,mamicode.com
首页 > 其他好文 > 详细

判断字符串是否包含汉字

时间:2018-03-14 19:38:09      阅读:132      评论:0      收藏:0      [点我收藏+]

标签:oid   log   []   ati   chinese   字符   static   import   mat   

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;
}
}

判断字符串是否包含汉字

标签:oid   log   []   ati   chinese   字符   static   import   mat   

原文地址:https://www.cnblogs.com/SEC-fsq/p/8569537.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!