L'errore stava nel replace che sostituiva un ' alla volta e non globalmente