import re


def expand_distances(d_expression):
    """
    Check if a distance expression contains at least one term d[x]. If yes, then
    the distances are expanded and we assume the user has specified an
    expression such as d[0] + d[2].
    """
    regexpr = re.compile(r'.*d\[\d*\].*')
    if regexpr.match(d_expression):
        return True
    return False