Update kebab.md

Resolves #212
This commit is contained in:
Isabelle Viktoria Maciohsek
2020-08-10 10:13:25 +03:00
committed by GitHub
parent e1d31b9661
commit 2662a1c1e2

View File

@ -11,11 +11,10 @@ Break the string into words and combine them adding `-` as a separator, using a
from re import sub from re import sub
def kebab(s): def kebab(s):
return sub( return '-'.join(
r"(\s|_|-)+","-", sub(r"(\s|_|-)+"," ",
sub( sub(r"[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+",
r"[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+", lambda mo: ' ' + mo.group(0).lower(), s)).split())
lambda mo: mo.group(0).lower(), s))
``` ```
```py ```py