and the problem im having is subtracting the index before and after i from the string.
I agree with the group, to read 3 characters from your string at a time, then store them in past, current, and next
it is true that you would like to know what past is, but this is handled as you iterate through your string.
special cases: for the first character you will have no past, and for the last character you will have no next.
you are working with current. so for your first character you write a special case for it before you jump into your loop.
when you are running your loop start by only caring about what current wants. check it for being an E then do accordingly,
move all your variables over, and store past every time. since past has been checked for Es on both sides it is safe to add!
then update next by collecting it from your string. repeat the loop until you meet the end condition and write code to handle the second special case.