import re


def read_wordlist(filename, format='diceware'):
    """
    Return a list of the words in the wordlist `filename`.
    """
    if format == 'diceware':
        expression = re.compile(r"^\d{5}\t(?P<word>\S+)$")
    elif format == 'simple':
        expression = re.compile(r"^(?P<word>\S+)$")
    else:
        raise ValueError(
            '"{}"is not a supported word list format.'.format(format))

    words = []
    with open(filename, 'r') as file_:
        for line in file_:
            match = expression.match(line)
            if match:
                word = match.group('word')
                words.append(word)
    return words