Here you can find the source of isIpV4StrValid(String str)
Parameter | Description |
---|---|
str | IP string(without *). |
public static boolean isIpV4StrValid(String str)
//package com.java2s; import java.util.regex.Pattern; public class Main { /**/*from w w w.ja v a 2 s. co m*/ * check if IP v4 string is valid. * * @param str * IP string(without *). * @return true if valid, false if not. */ public static boolean isIpV4StrValid(String str) { Pattern pattern = Pattern.compile( "^((\\d|[1-9]\\d|1\\d\\d|2[0-4]\\d|25[0-5]" + ")\\.){3}(\\d|[1-9]\\d|1\\d\\d|2[0-4]\\d|25[0-5])$"); return pattern.matcher(str).matches(); } }