1
1
mirror of https://github.com/theoludwig/programming-challenges.git synced 2024-10-29 22:17:23 +01:00

feat(challenges): add slugify

This commit is contained in:
Divlo 2021-11-10 20:08:25 +01:00
parent d18ca22470
commit 2f60b3f73d
No known key found for this signature in database
GPG Key ID: 6F24DA54DA3967CF
14 changed files with 72 additions and 0 deletions

View File

@ -0,0 +1,60 @@
# slugify
Created by [@Divlo](https://github.com/Divlo) 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
```txt
hello world
```
#### Output
```txt
hello-world
```
### Example 2
#### Input
```txt
--hello world--
```
### Output
```txt
hello-world
```
### Example 3
#### Input
```txt
😄 emoji
```
### Output
```txt
emoji
```
See the `test` folder for examples of input/output.

View File

View File

@ -0,0 +1 @@
hello world

View File

@ -0,0 +1 @@
hello-world

View File

@ -0,0 +1 @@
--hello world--

View File

@ -0,0 +1 @@
hello-world

View File

@ -0,0 +1 @@
😄 emoji

View File

@ -0,0 +1 @@
-emoji

View File

@ -0,0 +1 @@
slug

View File

@ -0,0 +1 @@
slug

View File

@ -0,0 +1 @@
slugify

View File

@ -0,0 +1 @@
slugify

View File

@ -0,0 +1 @@
programming-challenges

View File

@ -0,0 +1 @@
programming-challenges