import re


def distribute(string, delim, groups=[r'\S+', r'\S+']):
    """Distributes one part of a string to other parts of that string (seperated
    by a delimiter), returning a list of strings.

    Args:
        string: input string
        delim: regex matching delimiter between two parts of string to be
            distributed upon
        groups: list of regular expressions that match the parts of the string
            receiving the distributed portion of the string.
            defaults to [r'\S+', r'\S+'] (i.e. two blocks of non-whitespace)

    Returns:
        If delimiter and groups are found, returns a list of strings.
        If they are not found, returns a list containing just the original
            string.

    Examples:
        >>> distribute('hot spam/eggs', r'/')
        ['hot spam', 'hot eggs']
        >>> distribute('hot spam/eggs on toast', r'/')
        ['hot spam on toast', 'hot eggs on toast']
        >>> distribute('hot spam/eggs on toast', r'/', [r'\S+', r'\S+ on toast'])
        ['hot spam', 'hot eggs on toast']
    """
    output = []
    n = len(re.findall(delim, string)) + 1
    gps = groups + [groups[-1]] * (n - len(groups))
    rx = re.compile(delim.join([r'(' + group + r')' for group in gps]))
    re_match = rx.search(string)
    if re_match:
        output = [rx.sub(re_match.group(i), string) for i in range(1, n+1)]
    else:
        return [string]

    return output