1
1
mirror of https://github.com/theoludwig/programming-challenges.git synced 2024-07-18 02:20:12 +02:00
programming-challenges/challenges/slugify
2023-08-10 11:13:06 +02:00
..
solutions fix(solutions): memory issues thanks to -fsanitize=address flag with gcc 2023-08-10 11:13:06 +02:00
test feat(challenges): add slugify 2021-11-10 20:08:25 +01:00
README.md fix: update author - Théo LUDWIG 2023-07-02 17:28:54 +02:00

slugify

Created by @theoludwig on 10 November 2021.

Instructions

Write a function that generates a slug from a string.

A Slug is the unique identifying part of a web address, typically at the end of the URL.

The rules for generating a slug are as follows (kebab-case):

  • Replace spaces with hyphens.
  • Remove all non-alphanumeric characters.

Examples

Example 1

Input

hello world

Output

hello-world

Example 2

Input

--hello world--

Output

hello-world

Example 3

Input

😄 emoji

Output

emoji

See the test folder for examples of input/output.