@SuppressWarnings({"regex","deterministic"}) public static boolean isRegex(String s,int groups){
  Pattern p;
  try {
    p=Pattern.compile(s);
  }
 catch (  PatternSyntaxException e) {
    return false;
  }
  return getGroupCount(p) >= groups;
}

@ SuppressWarnings ( { "regex" , "deterministic" } ) public static boolean isRegex ( String s , int groups ) { Pattern p ; try { p = Pattern . compile ( s ) ; } catch ( PatternSyntaxException e ) { return false ; } return getGroupCount ( p ) >= groups ; }
returns true if the argument is a syntactically valid regular expression with at least the given number of groups .
