return the index of the first different character
split the string into three parts: before, at, and after the passed index