Java IP Regex Pattern
String pattern = "([01]?[0-9]{1,2}|2[0-4][0-9]|25[0-5])";
Grontourismo
String pattern = "([01]?[0-9]{1,2}|2[0-4][0-9]|25[0-5])";
public static boolean isIP(String ip) {
Pattern p = Pattern.compile("(([01]?[0-9]{1,2}|2[0-4][0-9]|25[0-5])\\.){3}([01]?[0-9]{1,2}|2[0-4][0-9]|25[0-5])");
Matcher m = p.matcher(ip);
return m.matches();
}