[Solved] Split string on capital letter and a capital letter followed by a lowercase letter [closed]


I’m trying to give an answer that will help you understanding the problem and work on the solution.

You have a string with capital letters and at some point there is a small letter. You want the string to be split at the position before the first small letter. You can iterate through the string and find the first small letter, remember that position and split the string there.

This is neither regex nor fast, but simple and verbose:

input_string = 'TESTTest'
for pos, letter in enumerate(input_string):
  if letter.islower() and letter.isalpha():
    split_position = pos-1
    break
first_part = input_string[:split_position]
second_part = input_string[split_position:]

solved Split string on capital letter and a capital letter followed by a lowercase letter [closed]