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.io.*;importjava.util.*;importjava.util.regex.Pattern;importjava.util.regex.Matcher;publicclassSolution{publicstaticvoidmain(String[]args){Scannerscanner=newScanner(System.in);// Pattern pattern = Pattern.compile("^...\\....\\....\\....$"); \\WORKS// Pattern pattern = Pattern.compile("^.{3}\\..{3}\\..{3}\\..{3}$"); \\WORKSPatternpattern=Pattern.compile("^(.{3}\\.){3}.{3}$");Matchermatcher=pattern.matcher(scanner.next());booleanfound=matcher.find();System.out.println(found);}}/*^ means starting with$ means ending. used to represent any character other than \n\\. used to represent original dota{3} means aaa*/
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Matching Anything But a Newline
You are viewing a single comment's thread. Return to all comments →
Java 15