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.
- Prepare
- Java
- Strings
- Pattern Syntax Checker
- Discussions
Pattern Syntax Checker
Pattern Syntax Checker
Sort by
recency
|
397 Discussions
|
Please Login in order to post a comment
Java 8 solution:
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(); //Write your code try{ Pattern.compile(pattern); System.out.println("Valid"); } catch(PatternSyntaxException e) { System.out.println("Invalid"); } testCases--; } in.close(); } }
Here is Pattern Syntax Checker solution in Java - https://programmingoneonone.com/hackerrank-pattern-syntax-checker-solution-in-java.html
Java 8