@SuppressWarnings({"regex","not.sef"}) public static String regexError(String s,int groups){
  try {
    Pattern p=Pattern.compile(s);
    int actualGroups=getGroupCount(p);
    if (actualGroups < groups) {
      return regexErrorMessage(s,groups,actualGroups);
    }
  }
 catch (  PatternSyntaxException e) {
    return e.getMessage();
  }
  return null;
}

@ SuppressWarnings ( { "regex" , "not.sef" } ) public static String regexError ( String s , int groups ) { try { Pattern p = Pattern . compile ( s ) ; int actualGroups = getGroupCount ( p ) ; if ( actualGroups < groups ) { return regexErrorMessage ( s , groups , actualGroups ) ; } } catch ( PatternSyntaxException e ) { return e . getMessage ( ) ; } return null ; }
returns null if the argument is a syntactically valid regular expression with at least the given number of groups . otherwise returns a string describing why the argument is not a regex .
