Created
September 21, 2016 15:23
-
-
Save vu3jej/56057e2d17bf16302429ffefdcc5ea7c to your computer and use it in GitHub Desktop.
camelCase ==> snake_case
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def slytherin(string): | |
"""Convert & return strings in camelCase to snake_case""" | |
tmp = re.sub(pattern=r'(.)([A-Z][a-z]+)', repl=r'\1_\2', string=string) | |
return re.sub(pattern=r'([a-z0-9])([A-Z])', repl=r'\1_\2', string=tmp)\ | |
.lower() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment