IP地址验证

/**
* 验证IP地址
* 
* @param 待验证的字符串
* @return 如果是符合格式的字符串,返回 <b>true </b>,否则为 <b>false </b>
*/
public static boolean isIP(String str) {
String num = "(25[0-5]|2[0-4]\d|[0-1]\d{2}|[1-9]?\d)";
String regex = "^" + num + "\." + num + "\." + num + "\." + num + "$";
return match(regex, str);
}
原文地址:https://www.cnblogs.com/20gg-com/p/6037439.html