def _split_camel_case(string):
tokens = []
token = []
for prev, char, next in zip(' ' + string, string, string[1:] + ' '):
print(prev, char, next)
if _is_camel_case_boundary(prev, char, next):
if token:
tokens.append(''.join(token))
token = [char]
else:
token.append(char)
print('token',token)
print('tokens',tokens)
if token:
tokens.append(''.join(token))
return tokens
def _is_camel_case_boundary(prev, char, next):
if prev.isdigit():
return not char.isdigit()
if char.isupper():
return next.islower() or prev.isalpha() and not prev.isupper()
return char.isdigit()
print(_split_camel_case('caseLooksGood'))
# string = 'looksGood'
# print(list(zip(' ' + string, string, string[1:] + ' ')))