STUD
← Plays

Build · Create · Engineering

Slugify function

A correct slugify(text) that passes the held-out cases.

You receive: A reviewed slugify function + the passing test report.

Part of Ship MVP

Example

A sample of what this play produces. Your result is generated for your inputs.

import re

def slugify(text):
    """Lowercase the text, collapse every run of non-alphanumeric characters
    (spaces, punctuation, underscores, non-ASCII letters) to a single hyphen,
    and trim leading and trailing hyphens. ASCII slug: accented letters are
    separators, not transliterated, so "Cafe au lait" and "Café au lait"
    both end in plain ASCII. Example: slugify("Top 10 Tips") == "top-10-tips".
    Authored for STUD (stud.com) as the play's sample deliverable."""
    slug = re.sub(r"[^a-z0-9]+", "-", str(text).lower())
    return slug.strip("-")

Opens later

This play is not open to run yet, so it has no price. Leave your email and STUD will tell you when it opens.

Scope of the check

What's verified: STUD verifies your slugify(text) reproduces the reference slug on held-out cases: the text is lowercased, every run of non-alphanumeric characters is collapsed to a single hyphen, and leading and trailing hyphens are trimmed. Non-ASCII letters are treated as separators, not transliterated, so 'Café au lait' becomes 'caf-au-lait'. STUD does NOT check performance, code style, or any behavior beyond matching the reference output.