From 6271c237545426746614bb68f41c09aafdc19951 Mon Sep 17 00:00:00 2001 From: Angelos Chalaris Date: Mon, 30 Sep 2019 22:14:54 +0300 Subject: [PATCH 1/2] Fix snake snippet Resolves #114 --- snippets/snake.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/snippets/snake.md b/snippets/snake.md index efb49396e..b8376fe73 100644 --- a/snippets/snake.md +++ b/snippets/snake.md @@ -11,15 +11,15 @@ Break the string into words and combine them adding `_-_` as a separator, using import re def snake(str): - return re.sub(r"(\s|_|-)+","-", + return 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).lower(),str) ) ``` ```py -snake('camelCase'); # 'camel_case' -snake('some text'); # 'some_text' -snake('some-mixed_string With spaces_underscores-and-hyphens'); # 'some_mixed_string_with_spaces_underscores_and_hyphens' -snake('AllThe-small Things'); # "all_the_smal_things" +snake('camelCase') # 'camel_case' +snake('some text') # 'some_text' +snake('some-mixed_string With spaces_underscores-and-hyphens') # 'some_mixed_string_with_spaces_underscores_and_hyphens' +snake('AllThe-small Things') # "all_the_smal_things" ``` From 14c41e7885707151708e6e4bfb46507588ac8cf0 Mon Sep 17 00:00:00 2001 From: 30secondsofcode <30secondsofcode@gmail.com> Date: Mon, 30 Sep 2019 19:16:46 +0000 Subject: [PATCH 2/2] Travis build: 125 --- README.md | 10 +++++----- snippet_data/snippetList.json | 2 +- snippet_data/snippets.json | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 55b9e6340..efede5aae 100644 --- a/README.md +++ b/README.md @@ -1844,7 +1844,7 @@ Break the string into words and combine them adding `_-_` as a separator, using import re def snake(str): - return re.sub(r"(\s|_|-)+","-", + return 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).lower(),str) ) @@ -1854,10 +1854,10 @@ def snake(str): Examples ```py -snake('camelCase'); # 'camel_case' -snake('some text'); # 'some_text' -snake('some-mixed_string With spaces_underscores-and-hyphens'); # 'some_mixed_string_with_spaces_underscores_and_hyphens' -snake('AllThe-small Things'); # "all_the_smal_things" +snake('camelCase') # 'camel_case' +snake('some text') # 'some_text' +snake('some-mixed_string With spaces_underscores-and-hyphens') # 'some_mixed_string_with_spaces_underscores_and_hyphens' +snake('AllThe-small Things') # "all_the_smal_things" ``` diff --git a/snippet_data/snippetList.json b/snippet_data/snippetList.json index e4bbd72c9..a5bedb2f3 100644 --- a/snippet_data/snippetList.json +++ b/snippet_data/snippetList.json @@ -943,7 +943,7 @@ ] }, "meta": { - "hash": "feeb43ff081fec564133b44bd6c748bc219756c0178ef0df98a790bbbaf17d78" + "hash": "4217b274beb495919f1aa33afe8e910d04776c35685f01ba4b3fcdd0b176e6e1" } }, { diff --git a/snippet_data/snippets.json b/snippet_data/snippets.json index 38b3a8874..f6cedee0d 100644 --- a/snippet_data/snippets.json +++ b/snippet_data/snippets.json @@ -1238,8 +1238,8 @@ "fileName": "snake.md", "text": "Converts a string to snake case.\n\nBreak the string into words and combine them adding `_-_` as a separator, using a regexp.\n\n", "codeBlocks": { - "code": "import re\n\ndef snake(str):\n return re.sub(r\"(\\s|_|-)+\",\"-\",\n re.sub(r\"[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+\",\n lambda mo: mo.group(0).lower(),str)\n )", - "example": "snake('camelCase'); # 'camel_case'\nsnake('some text'); # 'some_text'\nsnake('some-mixed_string With spaces_underscores-and-hyphens'); # 'some_mixed_string_with_spaces_underscores_and_hyphens'\nsnake('AllThe-small Things'); # \"all_the_smal_things\"" + "code": "import re\n\ndef snake(str):\n return re.sub(r\"(\\s|_|-)+\",\"_\",\n re.sub(r\"[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+\",\n lambda mo: mo.group(0).lower(),str)\n )", + "example": "snake('camelCase') # 'camel_case'\nsnake('some text') # 'some_text'\nsnake('some-mixed_string With spaces_underscores-and-hyphens') # 'some_mixed_string_with_spaces_underscores_and_hyphens'\nsnake('AllThe-small Things') # \"all_the_smal_things\"" }, "tags": [ "string", @@ -1248,7 +1248,7 @@ ] }, "meta": { - "hash": "feeb43ff081fec564133b44bd6c748bc219756c0178ef0df98a790bbbaf17d78" + "hash": "4217b274beb495919f1aa33afe8e910d04776c35685f01ba4b3fcdd0b176e6e1" } }, {