mirror of
https://github.com/theoludwig/programming-challenges.git
synced 2024-12-08 00:45:29 +01:00
feat(challenges): add slugify
This commit is contained in:
parent
d18ca22470
commit
2f60b3f73d
60
challenges/slugify/README.md
Normal file
60
challenges/slugify/README.md
Normal 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.
|
0
challenges/slugify/solutions/.gitkeep
Normal file
0
challenges/slugify/solutions/.gitkeep
Normal file
1
challenges/slugify/test/1/input.txt
Normal file
1
challenges/slugify/test/1/input.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
hello world
|
1
challenges/slugify/test/1/output.txt
Normal file
1
challenges/slugify/test/1/output.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
hello-world
|
1
challenges/slugify/test/2/input.txt
Normal file
1
challenges/slugify/test/2/input.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
--hello world--
|
1
challenges/slugify/test/2/output.txt
Normal file
1
challenges/slugify/test/2/output.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
hello-world
|
1
challenges/slugify/test/3/input.txt
Normal file
1
challenges/slugify/test/3/input.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
😄 emoji
|
1
challenges/slugify/test/3/output.txt
Normal file
1
challenges/slugify/test/3/output.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
-emoji
|
1
challenges/slugify/test/4/input.txt
Normal file
1
challenges/slugify/test/4/input.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
slug
|
1
challenges/slugify/test/4/output.txt
Normal file
1
challenges/slugify/test/4/output.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
slug
|
1
challenges/slugify/test/5/input.txt
Normal file
1
challenges/slugify/test/5/input.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
slugify
|
1
challenges/slugify/test/5/output.txt
Normal file
1
challenges/slugify/test/5/output.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
slugify
|
1
challenges/slugify/test/6/input.txt
Normal file
1
challenges/slugify/test/6/input.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
programming-challenges
|
1
challenges/slugify/test/6/output.txt
Normal file
1
challenges/slugify/test/6/output.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
programming-challenges
|
Loading…
Reference in New Issue
Block a user