正则匹配内容是否含有除汉字数字英文以外的字符

/** 
     * 检查输入的数据中是否有除了汉字字母和数字以外的字符
    * @param qString 要检查的数据 
    * @return boolean 如果包含正则表达式 regx 中定义的特殊字符,返回true; 
    * 否则返回false 
     */ 
     public static boolean hasCrossScriptRisk(String qString) {
    if (qString!=null) { 
     qString = qString.trim();
     String regex = "^[a-zA-Z0-9\u4E00-\u9FA5]+$";
Pattern pattern = Pattern.compile(regex);
Matcher match = pattern.matcher(qString);
boolean b = match.matches();
if (b) {
System.out.println(">>> 1");
return false;
} else {
System.out.println(">>> 2");
return true;
}
    }
return false;
     }

你可能感兴趣的:(正则,数字,字母,汉字)