def expand_chars(raw_str, target, repl): # {{{
    if target not in raw_str:
        return raw_str

    out = ''
    for char_group in [''.join(g) for k, g in groupby(raw_str)]:
        if char_group == target:
            if repl:
                out += repl
            else:
                out += ''
        elif char_group.startswith(target):
            out += char_group[:-1]
        else:
            out += char_group

    return out
Expand the character (target) in a string (raw_str) with another
dataset/ETHPy150Open chautoni/tube.vim/autoload/tube/utils/misc.py/expand_chars