Skip to content

Instantly share code, notes, and snippets.

@BlogBlocks
Last active July 18, 2018 03:41
Show Gist options
  • Select an option

  • Save BlogBlocks/76663365e1c77ad6ba19c25009001c03 to your computer and use it in GitHub Desktop.

Select an option

Save BlogBlocks/76663365e1c77ad6ba19c25009001c03 to your computer and use it in GitHub Desktop.
# 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