I have a StringBuffer named "sentence." I need to replace all occurrences of "A", except occurrences of "A" at the end of a word, with "E".

Example: ABABA ---> EBEBA

However, my code returns...