fix wscan error on too few numbers

trimmed search text and fix wscan substring failing when there are too
few characters in the search string