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.
importjava.util.regex.Matcher;importjava.util.regex.Pattern;importjava.util.Scanner;classSolution{publicstaticvoidmain(String[]args){Scannerin=newScanner(System.in);while(in.hasNext()){StringIP=in.next();System.out.println(IP.matches(newMyRegex().pattern));}}}classMyRegex{Stringp="(([0-1]?[0-9]?[0-9])|(2[0-4][0-9])|(25[0-5]))";//String p = "(([0-1]?([0-9]{1,2}))|(2[0-4][0-9])|(25[0-5]))";Stringpattern=p+"."+p+"."+p+"."+p;}
Cookie support is required to access HackerRank
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 →