public static Optional<String> findFirst(final String pattern, final Collection elements) {
        val compiledPattern = createPattern(pattern);
        return elements
            .stream()
            .filter(entry -> find(compiledPattern, entry.toString()))
            .findFirst();
    }
Find first in the list of items provided.

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