import re


def slugify(text, delim='-'):
    """Generates a slug."""
    punc = r'[\t !"#$%&\'()*\-/<=>?@\[\\\]^_`{|},.]+'
    result = []
    for word in re.split(punc, text.lower()):
        if word:
            result.append(word)
    return delim.join(result)