Java IP Address Validate isIpFormat(String ip)

Here you can find the source of isIpFormat(String ip)

Description

ip address verification

License

Apache License

Parameter

Parameter Description
ip a parameter

Return

true if is ip address

Declaration

public static boolean isIpFormat(String ip) 

Method Source Code

//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();
    }
}

Related

  1. isIpAddress(String ipAddress)
  2. isIPAddress(String ipAddress)
  3. isIPAddress(String line)
  4. isIpAddress(String str)
  5. isIPAndPort(String text)
  6. isIPSect(String ip)
  7. isIPString(String str)
  8. isIpv4(String ipv4)
  9. isIpV4Address(CharSequence address)