public class CheckStrUtil {
/**
* 数字判断
* @param str
* @return
*/
public static boolean isNumber(String str){
Pattern pattern = Pattern.compile(".*\\d.*");
return pattern.matcher(str).matches();
}
/**
* 大写判断
* @param str
* @return
*/
public static boolean isUpper(String str){
Pattern pattern = Pattern.compile(".*[A-Z].*");
return pattern.matcher(str).matches();
}
/**
* 小写判断
* @param str
* @return
*/
public static boolean isSmall(String str){
Pattern pattern = Pattern.compile(".*[a-z].*");
return pattern.matcher(str).matches();
}
/**
* 特殊字符判断
* @param str
* @return
*/
public static boolean isSpcStr(String str){
Pattern pattern = Pattern.compile(".*\\W.*");
return pattern.matcher(str).matches();
}
}
java工具类:正则表达式验证字符串中包含的大,小写字母,特殊符号,数字
最新推荐文章于 2025-02-09 11:02:52 发布

1万+

被折叠的 条评论
为什么被折叠?



