Trim whitespace before replacing it with a dash.