diff --git a/Java/Regex.java b/Java/Regex.java index c9f7c05..aee5301 100644 --- a/Java/Regex.java +++ b/Java/Regex.java @@ -1,5 +1,5 @@ public static boolean isIp(String ip) { - return ip.matches("^(?:(?: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]?)$"); + return ip != null && !ip.equals("") && ip.matches("^(?:(?: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]?)$"); }