@Override
    public Map<String, List<Object>> getAttributesInternal(final RegisteredServiceAttributeReleasePolicyContext context,
                                                           final Map<String, List<Object>> attributes) {
        return allowedAttributes
            .entrySet()
            .stream()
            .filter(entry -> attributes.containsKey(entry.getKey()))
            .map(entry -> {
                val rule = entry.getValue();

                val valuePattern = RegexUtils.createPattern(rule.getPattern());
                val transformPattern = PATTERN_TRANSFORM_GROUPS.matcher(rule.getTransform());

                val attributeValues = attributes.get(entry.getKey());
                val transformedValues = attributeValues
                    .stream()
                    .map(value -> {
                        var transformedValue = rule.getTransform();
                        val matcher = valuePattern.matcher(value.toString());
                        if (matcher.find()) {
                            while (transformPattern.find()) {
                                val group = Integer.parseInt(transformPattern.group(1));
                                val target = String.format("${%s}", group);
                                transformedValue = transformedValue.replace(target, matcher.group(group));
                            }
                        }
                        transformPattern.reset();
                        return transformedValue;
                    })
                    .collect(Collectors.<Object>toList());
                return Pair.of(entry.getKey(), transformedValues);
            })
            .filter(pair -> !pair.getValue().isEmpty())
            .collect(Collectors.toMap(Pair::getKey, Pair::getValue));
    }
This is {@link PatternMatchingAttributeReleasePolicy}.

@author Misagh Moayyed
@since 6.6.0
core/cas-server-core-authentication-attributes/src/main/java/org/apereo/cas/services/PatternMatchingAttributeReleasePolicy.java