//用来判断ip是否合法
public boolean checkIp(String tempIp) {
String regex = "(25[0-5]|2[0-4]\\d|1\\d{2}|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d{2}|[1-9]?\\d)){3}";
Pattern p = Pattern.compile(regex);
Matcher m = p.matcher(tempIp);
return m.matches();
}
微信扫一扫
//用来判断ip是否合法
public boolean checkIp(String tempIp) {
String regex = "(25[0-5]|2[0-4]\\d|1\\d{2}|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d{2}|[1-9]?\\d)){3}";
Pattern p = Pattern.compile(regex);
Matcher m = p.matcher(tempIp);
return m.matches();
}
相关推荐