Travis build: 189

This commit is contained in:
30secondsofcode
2019-10-31 07:39:05 +00:00
parent 17a4faf07a
commit 80776131a5
3 changed files with 9 additions and 7 deletions

View File

@ -1761,13 +1761,15 @@ 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, `title()` and `lower`.
Use `re.sub()` to replace any `-`,`_` or ` ` (space) with a space, using the regexp `r"(_|-)+"`.
Use `title()` to capitalize the first letter of each word convert the rest to lowercase.
Finally, use `replace()` to remove spaces between words.
```py
import re
def camel(s):
s = re.sub(r"(\s|_|-)+", " ", s).title().replace(" ", "")
s = re.sub(r"(_|-)+", " ", s).title().replace(" ", "")
return s[0].lower() + s[1:]
```