def extract(expr, name, name_index):
    """extract named part of expression, using name_index

    :param str expr: the lucene expression
    :param str name: name of the part to extract
    :param dict name_index: the dict obtained from :py:func:`name_index`
    """
    return expr[name_index[name][0]:name_index[name][0] + name_index[name][1]]
