Gültiges Regex -Check Java

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