Add smart string trim function.