def replace(string, data):
    """
    Replaces the data occurrences in the string.

    Parameters
    ----------
    string : str or unicode
        String to manipulate.
    data : dict
        Replacement occurrences.

    Returns
    -------
    unicode
        Manipulated string.

    Examples
    --------
    >>> patterns = {'John' : 'Luke',
    ...             'Jane' : 'Anakin',
    ...             'Doe' : 'Skywalker',
    ...             'Z6PO' : 'R2D2'}
    >>> data = 'Users are: John Doe, Jane Doe, Z6PO.'
    >>> replace(data,patterns )
    u'Users are: Luke Skywalker, Anakin Skywalker, R2D2.'
    """

    for old, new in data.iteritems():
        string = string.replace(old, new)
    return string