Function trimString