String rexp = "^((25[0-5]|2[0-4]\\d|[1]{1}\\d{1}\\d{1}|[1-9]{1}\\d{1}|\\d{1})($|(?!\\.$)\\.)){4}$";
Pattern pat = Pattern.compile(rexp);
Matcher mat = pat.matcher(saveIp);
boolean ipAddress = mat.find();
如果
ipAddress==true 则ip 正确
String rexp = "^((25[0-5]|2[0-4]\\d|[1]{1}\\d{1}\\d{1}|[1-9]{1}\\d{1}|\\d{1})($|(?!\\.$)\\.)){4}$";
Pattern pat = Pattern.compile(rexp);
Matcher mat = pat.matcher(saveIp);
boolean ipAddress = mat.find();
如果
ipAddress==true 则ip 正确