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. 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 ```py
import re import re
def camel(s): def camel(s):
s = re.sub(r"(\s|_|-)+", " ", s).title().replace(" ", "") s = re.sub(r"(_|-)+", " ", s).title().replace(" ", "")
return s[0].lower() + s[1:] return s[0].lower() + s[1:]
``` ```

View File

@ -114,7 +114,7 @@
"type": "snippetListing", "type": "snippetListing",
"title": "camel", "title": "camel",
"attributes": { "attributes": {
"text": "Converts a string to camelcase.\n\nBreak the string into words and combine them capitalizing the first letter of each word, using a regexp, `title()` and `lower`.\n\n", "text": "Converts a string to camelcase.\n\nUse `re.sub()` to replace any `-`,`_` or ` ` (space) with a space, using the regexp `r\"(_|-)+\"`.\nUse `title()` to capitalize the first letter of each word convert the rest to lowercase.\nFinally, use `replace()` to remove spaces between words.\n\n",
"tags": [ "tags": [
"string", "string",
"regexp", "regexp",
@ -122,7 +122,7 @@
] ]
}, },
"meta": { "meta": {
"hash": "60b308cb7f28b676fb122949d04ae07af0d4e0fcb96f037b3aa3c09be9b2e7ab" "hash": "9df97be0166e2a4a90859e878f986c0adb539ac41b85aac9c05e4dd0999155b5"
} }
}, },
{ {

View File

@ -150,9 +150,9 @@
"type": "snippet", "type": "snippet",
"attributes": { "attributes": {
"fileName": "camel.md", "fileName": "camel.md",
"text": "Converts a string to camelcase.\n\nBreak the string into words and combine them capitalizing the first letter of each word, using a regexp, `title()` and `lower`.\n\n", "text": "Converts a string to camelcase.\n\nUse `re.sub()` to replace any `-`,`_` or ` ` (space) with a space, using the regexp `r\"(_|-)+\"`.\nUse `title()` to capitalize the first letter of each word convert the rest to lowercase.\nFinally, use `replace()` to remove spaces between words.\n\n",
"codeBlocks": { "codeBlocks": {
"code": "import re\n\ndef camel(s):\n s = re.sub(r\"(\\s|_|-)+\", \" \", s).title().replace(\" \", \"\")\n return s[0].lower() + s[1:]", "code": "import re\n\ndef camel(s):\n s = re.sub(r\"(_|-)+\", \" \", s).title().replace(\" \", \"\")\n return s[0].lower() + s[1:]",
"example": "camel('some_database_field_name'); # 'someDatabaseFieldName'\ncamel('Some label that needs to be camelized'); # 'someLabelThatNeedsToBeCamelized'\ncamel('some-javascript-property'); # 'someJavascriptProperty'\ncamel('some-mixed_string with spaces_underscores-and-hyphens'); # 'someMixedStringWithSpacesUnderscoresAndHyphens'" "example": "camel('some_database_field_name'); # 'someDatabaseFieldName'\ncamel('Some label that needs to be camelized'); # 'someLabelThatNeedsToBeCamelized'\ncamel('some-javascript-property'); # 'someJavascriptProperty'\ncamel('some-mixed_string with spaces_underscores-and-hyphens'); # 'someMixedStringWithSpacesUnderscoresAndHyphens'"
}, },
"tags": [ "tags": [
@ -162,7 +162,7 @@
] ]
}, },
"meta": { "meta": {
"hash": "60b308cb7f28b676fb122949d04ae07af0d4e0fcb96f037b3aa3c09be9b2e7ab" "hash": "9df97be0166e2a4a90859e878f986c0adb539ac41b85aac9c05e4dd0999155b5"
} }
}, },
{ {