需要一个判断字符串中有没有中文的正则表达式,如果有就返回真,没有返回假

解决方案 »

  1.   

    匹配中文字符的正则表达式: [\u4e00-\u9fa5] 
      

  2.   

    这样可以static String regEx = "[\u4e00-\u9fa5]";
    static Pattern pat = Pattern.compile(regEx); public static boolean isContainsChinese(String str)
    {
    Matcher matcher = pat.matcher(str);
    boolean flg = false;
    if (matcher.find())
    {
    flg = true;
    }
    return flg; }