Created
May 10, 2021 15:11
-
-
Save MinSomai/dcee7d3b2d6e47dcd0afac58b8a8a35c to your computer and use it in GitHub Desktop.
Java | Pattern Syntax Checker - Hackerrank.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Scanner; | |
import java.util.regex.*; | |
public class Solution | |
{ | |
public static void main(String[] args){ | |
Scanner in = new Scanner(System.in); | |
int testCases = Integer.parseInt(in.nextLine()); | |
while(testCases>0){ | |
String pattern = in.nextLine(); | |
try{ | |
Pattern.compile(pattern); | |
System.out.println("Valid"); | |
}catch(Exception ignore){ | |
System.out.println("Invalid"); | |
} | |
testCases--; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment