Advertisement
Arnab_Manna

pattern checker

Mar 19th, 2023 (edited)
899
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.75 KB | None | 0 0
  1. import java.io.*;
  2. import java.util.*;
  3. import java.util.regex.*;
  4.  
  5. public class Solution {
  6.  
  7.     public static void main(String[] args) {
  8.         /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
  9.         Scanner in=new Scanner(System.in);
  10.         int tc=in.nextInt();
  11.        
  12.         for(i=1;i<=tc;i++)
  13.         {
  14.             boolean ch=true;
  15.             try{
  16.                 String st=in.nextLine();
  17.                 Pattern p=Pattern.compile(st);
  18.             }
  19.             catch(Exception E)
  20.             {
  21.                 System.out.println("Invalid");
  22.                 ch=false;
  23.             }
  24.             if(ch==true)
  25.                 System.out.println("Valid");
  26.         }
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement