in reply to Can we "grow" a string?

Do you mean you want to use substr?

You haven't shown any relevant code of your program, so it's hard for us to help you better. If you show what code you have already written, that helps us to give you more succinct answers.

Maybe you want to use a start position and a length, and decrease the start position and/or increase the length until your criteria are met. You haven't told us why/how you're arriving at FGHI, so it's hard to give you a different approach.