Java IP Address Validate isIp(String str)

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

Description

is Ip

License

Apache License

Declaration

public static boolean isIp(String str) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {
    public static boolean isIp(String str) {
        boolean result = validByRegex(
                "^(?:(?: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]?)$",
                str);//from ww  w.j  a v a 2s . co m
        return result;
    }

    public static boolean validByRegex(String regex, String str) {
        Pattern pattern = Pattern.compile(regex, Pattern.CASE_INSENSITIVE);
        Matcher regexMatcher = pattern.matcher(str);
        return regexMatcher.find();
    }
}

Related

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