Java IP Address Validate isIp(String s)

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

Description

is Ip

License

Open Source License

Parameter

Parameter Description
s a parameter

Declaration

public static boolean isIp(String s) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

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

public class Main {
    /**//from w w w  .  j ava2  s . c  o m
     * @param s
     * @return
     */
    public static boolean isIp(String s) {
        String strMatch = "^(\\d{1,2}|1\\d\\d|2[0-4]\\d|25[0-5])\\.(\\d{1,2}|1\\d\\d|2[0-4]\\d|25[0-5])\\.(\\d{1,2}|1\\d\\d|2[0-4]\\d|25[0-5])\\.(\\d{1,2}|1\\d\\d|2[0-4]\\d|25[0-5])$";
        Pattern ParsePattern = Pattern.compile(strMatch);
        Matcher ParseMatcher = ParsePattern.matcher(s);
        return ParseMatcher.find();
    }
}

Related

  1. isIP(String input)
  2. isIp(String ip)
  3. isIP(String ip)
  4. isIp(String ipAddress)
  5. isIP(String ipString)
  6. isIP(String src)
  7. isIP(String str)
  8. isIp(String str)
  9. isIp(String str)