updated README

This commit is contained in:
rshaghoulian
2017-02-09 02:34:19 -08:00
parent 354f4d9abb
commit 06704091ac
2 changed files with 22 additions and 14 deletions
+8 -14
View File
@@ -1,15 +1,9 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.Scanner;
class Solution{
public static void main(String []args){
Scanner in = new Scanner(System.in);
while(in.hasNext()){
String IP = in.next();
System.out.println(IP.matches(new MyRegex().pattern));
}
}
/*
[01]?\\d{1,2} matches numbers 0-199.
2[0-4]\\d matches numbers 200-249
25[0-5] matches numbers 250-255
*/
class MyRegex {
String num = "([01]?\\d{1,2}|2[0-4]\\d|25[0-5])";
String pattern = num + "." + num + "." + num + "." + num;
}