Here you can find the source of isIpFormat(String ip)
Parameter | Description |
---|---|
ip | a parameter |
public static boolean isIpFormat(String ip)
//package com.java2s; //License from project: Apache License import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main { /**/* w ww .j a v a 2 s. co m*/ * ip address verification * * @param ip * @return true if is ip address */ public static boolean isIpFormat(String ip) { String regEx = "^((?:(?:25[0-5]|2[0-4]\\d|((1\\d{2})|([1-9]?\\d)))\\.){3}(?:25[0-5]|2[0-4]\\d|((1\\d{2})|([1-9]?\\d))))$"; Pattern pat = Pattern.compile(regEx); Matcher mat = pat.matcher(ip); return mat.find(); } }