committed by
GitHub
parent
e1d31b9661
commit
2662a1c1e2
@ -11,11 +11,10 @@ Break the string into words and combine them adding `-` as a separator, using a
|
||||
from re import sub
|
||||
|
||||
def kebab(s):
|
||||
return sub(
|
||||
r"(\s|_|-)+","-",
|
||||
sub(
|
||||
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))
|
||||
return '-'.join(
|
||||
sub(r"(\s|_|-)+"," ",
|
||||
sub(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())
|
||||
```
|
||||
|
||||
```py
|
||||
|
||||
Reference in New Issue
Block a user