java顶用正则表达式判断中文字符串中是否含有英文或者数字
java中用正则表达式判断中文字符串中是否含有英文或者数字
public static boolean includingNUM(String str)throws Exception{
boolean f =M.matches();
return f;
public static boolean includingNUM(String str)throws Exception{
Pattern p = Pattern.compile("[\u4e00-\u9fa5]*[\\d|\\w]+[\u4e00-\u9fa5]*");
//或者 Pattern p = Pattern.compile("[\u4e00-\u9fa5]*[0-9|a-z|A-Z]+[\u4e00-\u9fa5]*");
boolean f =M.matches();
return f;
}
备注: java正则中:
\\D表示非数字
\\d表示数字
\\W表示非单词
\u4e00-\u9fa5是中文字符的编码范围
\\w表示单词
其中一个\是转义字符!!