/*** 验证字符串text是不是ip地址,是返回true,否则返回false* @param text* @return*/ public static boolean isIPAddress(String text){StringBuilder regex = new StringBuilder("^(1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|[1-9])\\."); regex.append("(1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|\\d)\\."); regex.append("(1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|\\d)\\."); regex.append("(1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|\\d)$"); if(text.matches(regex.toString())){ //返回判断信息 return true;}else{ return false; } }
转载于:https://www.cnblogs.com/llhua/p/3632294.html