Perchè non usi semplicemente un ciclio e confronti ogni carattere della stringa?