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));}}}//Write your code hereclassMyRegex{Stringpattern="^([01]?\\d{0,2}|25[0-5]|2[0-4]\\d)\\.([01]?\\d{0,2}|25[0-5]|2[0-4]\\d)\\.([01]?\\d{0,2}|25[0-5]|2[0-4]\\d)\\.([01]?\\d{0,2}|25[0-5]|2[0-4]\\d)$";}
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 →
My Solution