We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
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));
}
}
Java Regex
You are viewing a single comment's thread. Return to all comments →
class Solution{
}
`class MyRegex { String pattern = "^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\." + "(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\." + "(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\." + "(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$"; }