Pattern Syntax Checker

  • + 0 comments
    public class Solution
    {
    	public static void main(String[] args){
    		Scanner in = new Scanner(System.in);
    		while(in.hasNextLine()){
    			String pattern = in.nextLine();
              	try{
                  Pattern.compile(pattern);
                  System.out.println("Valid");
                  }
                  catch(Exception e ){
                      System.out.println("Invalid");
    
              }
        }
        in.close();
    }
    

    }