class RegexContainer {

    static <T> Optional<RegexContainer<T>> checkAndCreate(String maybeRegex, T content) {
        if (maybeRegex.startsWith("/") && maybeRegex.endsWith("/")) {
            try {
                Pattern regex = Pattern.compile(maybeRegex.substring(1, maybeRegex.length() - 1));
                return Optional.of(new RegexContainer<>(regex, content));
            } catch (PatternSyntaxException e) {
                return Optional.empty();
            }
        }
        return Optional.empty();
    }

      RegexContainer(Pattern regex, T content);

}