天天看点

Java 判断字符是否是中文汉字

[\u2E80-\u9FFF]+$ 匹配所有东亚区的语言,包含生僻字
 [\u4E00-\u9FFF]+$ 匹配简体和繁体,不包含生僻字
 [\u4E00-\u9FA5]+$ 匹配简体
           

例子:

/**
     * 校验是否全部是中文
     * 校验规则:账号中只能是有中文。
     * @param zj
     * @return 失败FALSE,成功:TRUE
     */
    public boolean JGZ(String zj){
        boolean flog = false;
         Matcher m = Pattern.compile("[\u2E80-\u9FFF]*").matcher(zj);  
        if(m.matches()){  
            flog = true;
        }
        return flog;
    }