Travis build: 43
This commit is contained in:
@ -1640,16 +1640,13 @@ byte_size('Hello World') # 11
|
||||
|
||||
Converts a string to camelcase.
|
||||
|
||||
Break the string into words and combine them capitalizing the first letter of each word, using a regexp.
|
||||
Break the string into words and combine them capitalizing the first letter of each word, using a regexp, `title()` and `lower`.
|
||||
|
||||
```py
|
||||
import re
|
||||
|
||||
def camel(str):
|
||||
s = re.sub(r"(\s|_|-)+","",
|
||||
re.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)[0].upper() + mo.group(0)[1:].lower(),str)
|
||||
)
|
||||
def camel(s):
|
||||
s = re.sub(r"(\s|_|-)+", " ", s).title().replace(" ", "")
|
||||
return s[0].lower() + s[1:]
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user