You are viewing a single comment's thread. Return to all comments →
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)); } } } class MyRegex{ static final String pattern = "((([0-1]?[0-9]{1,2})|(2[0-4][0-9])|(25[0-5])).){3}(([0-1]?[0-9]{1,2})|(2[0-4][0-9])|(25[0-5]))"; }
Seems like cookies are disabled on this browser, please enable them to open this website
Java Regex
You are viewing a single comment's thread. Return to all comments →