Skip to content

Instantly share code, notes, and snippets.

@juanarrivillaga
Last active October 5, 2017 18:38
Show Gist options
  • Save juanarrivillaga/f7c32f60c3a5bc70b40130f1c201c8da to your computer and use it in GitHub Desktop.
Save juanarrivillaga/f7c32f60c3a5bc70b40130f1c201c8da to your computer and use it in GitHub Desktop.
def split(n):
if len(n) < 1:
return '', ''
first = n[0]
rest = n[1:]
a, b = split(rest)
if first.islower() or first in ('_','.'):
return first + a, b
elif first.isupper() or first in (' ', '|'):
return a, first + b
else:
return a, b
# >>> split("'lMiED)teD5E,_hLAe;Nm,0@Dli&Eg ,#4aI?rN@T§&e7#4E #<(S0A?<)NT8<0'")
# ('lite_hemligare', 'MEDDELANDE INTE SANT')
# >>>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment