how to write regular expression for iP addresss in java code example
Example 1: ip address regex validate
^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$
Example 2: java regex ip
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();
}