Replace repetitions at the character level in `text` after the repetition

def replace_rep_after(text: str) -> str:
    "Replace repetitions at the character level in `text` after the repetition"

    def _replace_rep(m):
        c, cc = m.groups()
        return f"{c}{TK_REP}{len(cc)+1}"

    re_rep = re.compile(r"(\S)(\1{2,})")

    return re_rep.sub(_replace_rep, text)