public PathMatcher excludeRegex(final String regex) {
        warnRegexp();
        CommonHelper.assertNotBlank("regex", regex);

        if (!regex.startsWith("^") || !regex.endsWith("$")) {
            throw new TechnicalException("Your regular expression: '" + regex + "' must start with a ^ and end with a $ " +
                "to define a full path matching");
        }

        excludedPatterns.add(Pattern.compile(regex));
        return this;
    }
Any path matching this regex will be excluded.

@param regex the regular expression matching the paths to be excluded
@return this path matcher
pac4j-core/src/main/java/org/pac4j/core/matching/matcher/PathMatcher.java