Prawidłowe sprawdź regex Java

try{
     Pattern.compile(pattern);
     System.out.println("Valid");
   }
catch(PatternSyntaxException e)
   {
     System.out.println("Invalid");
   }
Nervous Newt