trim a string, ignore undefined