static String replaceSubstitution(String base, Pattern from, String to,
                                      boolean repeat) {
        Matcher match = from.matcher(base);
        if (repeat) {
            return match.replaceAll(to);
        } else {
            return match.replaceFirst(to);
        }
    }
Replace the matches of the from pattern in the base string with the value
of the to string.
@param base the string to transform
@param from the pattern to look for in the base string
@param to the string to replace matches of the pattern with
@param repeat whether the substitution should be repeated
@return
clients/src/main/java/org/apache/kafka/common/security/kerberos/KerberosRule.java