Java IP Address Validate isIP(String str)

Here you can find the source of isIP(String str)

Description

is IP

License

Open Source License

Declaration

public static boolean isIP(String str) 

Method Source Code


//package com.java2s;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {

    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);
    }/*from   w w w  .ja va2s.  co m*/

    private static boolean match(String regex, String str) {
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(str);
        return matcher.matches();
    }
}

Related

  1. isIP(String ip)
  2. isIp(String ipAddress)
  3. isIP(String ipString)
  4. isIp(String s)
  5. isIP(String src)
  6. isIp(String str)
  7. isIp(String str)
  8. isIP4(String val)
  9. isIPAddress(final String s)