From 7942a08c8471efffa1196755249e2e0dc7864e3e Mon Sep 17 00:00:00 2001 From: chteufleur Date: Thu, 3 Sep 2015 17:56:09 +0200 Subject: [PATCH] Add check IP string by regex --- Java/Regex.java | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 Java/Regex.java diff --git a/Java/Regex.java b/Java/Regex.java new file mode 100644 index 0000000..c9f7c05 --- /dev/null +++ b/Java/Regex.java @@ -0,0 +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]?)$"); +}