def _replace(replace_func, s):
    """
    inner function for :py:func:`replace_wildcard`

    :param replace_func: Callable[[char], char].
        Char to char function. eg f(a) = A, indicates %a should be replaced by A.
    :param s: str, that match r"[\%]+[^\%]*"
    :return: str, transformed after wildcard substitution
    """

    if len(s) <= 1:
        return s
    if s[0] != "%":
        return s
    if s[-1] == "%":
        return s
    if s[1] == "%":
        return s[1:]
    if s[1] != "%":
        return replace_func(s[1]) + s[2:]