code: public static String extractRegexGroup(String fromContent, String regex, int groupNumber) throws Exception {
          if (regex == null) {
              throw new Exception("Cannot extract regex group because the provided regular expression is null.");
          }
          Pattern expectedPattern = Pattern.compile(regex);
          return extractRegexGroup(fromContent, expectedPattern, groupNumber);
      }
docs: Extracts the specified matching group in the provided content. An exception is thrown if the group number is invalid
  (negative or greater than the number of groups found in the content), or if a matching group cannot be found in the
  content.