Last active
July 18, 2018 03:41
-
-
Save BlogBlocks/76663365e1c77ad6ba19c25009001c03 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| # USAGE example: | |
| # import UnCamel | |
| # x = "TimeToUncamelCaseTextUsingFunctions" | |
| # UnCamel.uncamel(x) | |
| def uncamel(x): | |
| return reduce(lambda a,b: a + ((b.upper() == b and (len(a) and a[-1].upper() != a[-1])) | |
| and (' ' + b) or b), x, '') | |
| def uncam(x): | |
| import re | |
| return re.sub("([a-z])([A-Z])","\g<1> \g<2>",x) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment