真正用到的时候,查找就发现很多都是错误的,所以还是自己整理将正确的代码记录一下吧。。
以下亲测可用,判断字符串是否符合IP地址格式
public static boolean isboolIp(String ipAddress) {
if (ipAddress.length() < 7 || ipAddress.length() > 15) {
return false;
}
/**
* 判断IP格式和范围
*/
String rexp = "([1-9]|[1-9]\d|1\d{2}|2[0-4]\d|25[0-5])(\.(\d|[1-9]\d|1\d{2}|2[0-4]\d|25[0-5])){3}";
Pattern pat = Pattern.compile(rexp);
Matcher mat = pat.matcher(ipAddress);
boolean flag = mat.matches();
return flag;
}
最后
以上就是懦弱夏天最近收集整理的关于java正则表达式判断男女,java正则表达式判断IP的全部内容,更多相关java正则表达式判断男女内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复