Add check IP string by regex

This commit is contained in:
chteufleur 2015-09-03 17:56:09 +02:00
parent f65c897fad
commit 7942a08c84
1 changed files with 5 additions and 0 deletions

5
Java/Regex.java Normal file
View File

@ -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]?)$");
}