String IPV4_REGEX = "\\A(25[0-5]|2[0-4]\\d|[0-1]?\\d?\\d)(\\.(25[0-5]|2[0-4]\\d|[0-1]?\\d?\\d)){3}\\z"; List<String> list = Arrays.asList(split); for (String item : list) { if(Pattern.matches(IPV4_REGEX, item) == false){ throw new Exception("存在不合规的ip"); } }
类似于上面的IPV4_REGEX
原文地址:https://www.cnblogs.com/chenmz1995/p/10454197.html
时间: 2024-10-07 23:27:32