Remove leading/trailing spaces from search string

Some keyboards insert a trailing space when doing word completion.