def process_backspaces(input, token='[BACKSPACE]'):
    """Delete character before an occurence of "token" in a string."""
output = ''
for item in (input + ' ').split(token):
    output += item
output = output[:-1]
return output

def process_shifts(input, token='[SHIFT]'):
    """Replace characters after an occurence of "token" with their uppecase 
    equivalent. (Doesn't turn "1" into "!" or "2" into "@", however!)."""
output = ''
for item in (' ' + input).split(token):
    output += item[0].upper() + item[1:]
return output
test_string = '[SHIFT]this isrd[BACKSPACE][BACKSPACE] an example file[SHIFT]1'
print(process_backspaces(process_shifts(test_string)))
Разбор строк в питоне