opt and fixed obu ip bug

This commit is contained in:
lixiaopeng
2022-05-19 11:21:15 +08:00
parent 435e7b37d5
commit d7b4689ff0
8 changed files with 32 additions and 35 deletions

View File

@@ -6,6 +6,7 @@ import androidx.annotation.Nullable;
import androidx.annotation.StringRes;
import java.util.IllegalFormatException;
import java.util.regex.Pattern;
/**
* <pre>
@@ -259,4 +260,17 @@ public final class StringUtils {
}
return text;
}
/**
* Ip校验
* @param ipAddress 单个ip
* @return
*/
public static boolean isValidIPAddress(String ipAddress) {
if ((ipAddress != null) && (!ipAddress.isEmpty())) {
return Pattern.matches("^([1-9]|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])(\\.(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])){3}$", ipAddress);
}
return false;
}
}