public static Optional<String> findFirst(final Collection<String> patterns, final Collection elements) {
        return patterns
            .stream()
            .map(RegexUtils::createPattern)
            .flatMap(compiledPattern -> elements.stream().filter(r -> find(compiledPattern, r.toString())))
            .findFirst();
    }
Find first matching pattern in the given collection of elements.

@param patterns the patterns
@param elements the elements
@return the optional
core/cas-server-core-util-api/src/main/java/org/apereo/cas/util/RegexUtils.java