def multiple_replace(text: str, rep: Dict[str, str]) -> str:
    """
    Returns a version of ``text`` in which the keys of ``rep`` (a dict) have
    been replaced by their values.

    As per
    http://stackoverflow.com/questions/6116978/python-replace-multiple-strings.
    """
    rep = dict((re.escape(k), v) for k, v in rep.items())
    pattern = re.compile("|".join(rep.keys()))
    return pattern.sub(lambda m: rep[re.escape(m.group(0))], text)