import re


def multiple_replace(string, replacements):
    """
    Given a string and a dictionary of replacements in the format:
        { <word_to_replace>: <replacement>, ... }
    Make all the replacements and return the new string.

    From: http://stackoverflow.com/questions/2400504/
    """
    pattern = re.compile('|'.join(replacements.keys()))
    return pattern.sub(lambda x: replacements[x.group()], string)