Android examples for java.net:IP Address
is string a valid Ip Address
import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main{ public static final String regIpAddress = "^([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\.([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\.([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\.([01]?\\d\\d?|2[0-4]\\d|25[0-5])$"; public static boolean isIp4Address(String text) { Pattern pattern = Pattern.compile(regIpAddress); Matcher macher = pattern.matcher(text); return macher.matches(); }// w ww. j a va2s . co m }