Your solution only works in the cases where the midpoint of the palindrome is the middle point of the string. You can use the more general following approach:
Consider each letter of the string to be the midpoint of a palindrome. Then look to the left and to the right of the current letter and check if the characters match. If they do check if the next pair of characters match. If they do not, consider the next character as the midpoint.
For example, consider the sting AEBCDCBGGGGG
You first consider the first $A$ to be the midpoint. Since it has no character to the left it cannot be a midpoint. You move on to the second letter, $E$ and consider it to be the midpoint. Next, you compare $A$ and $B$. Since they are not the same $E$ is not the midpoint of a palidrome. You consider $B$ as a midpoint. Again since $E$ and $C$ are not the same, $B$ cannot be the midpoint of a palindrome. After some steps, you will consider $D$ as a midpoint. This time its neighbouring letters are $C$ and $C$, therefore, $D$ is the midpoint of a palindrome. You move on to the next letters which are $B$ and $B$, so they are part of the palindrome. The next letters are $E$ and $G$, therefore they are not part of a palindrome. So you know that the string contains at least one palindrome, BCDCB. You continue traversing the string in the same way looking for more palindromes.