Pattern Syntax Checker

  • + 0 comments

    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--;
        }