Prova ad usare indexOF(char c) anziché LastIndexOf