Approach to mitigate operator input slackness or apparent extraneous search term constructs.

krakatoa
krakatoa used Ask the Experts™
on
How much effort do you Experts think should go into defensively 'protecting' a text input field (which will be used to obtain key search terms for a text search) from (possibly) irrelevant input from the operator, such as too many space characters, punctuation and other tokens which might not be helpful to an effective search strategy ? I'm relatively ok with implementing methods that are considered helpful, so this is not a request for coding assistance, but rather about approach and real-life search term management and oversight. (I suppose another way of putting the same point it that I wish to avoid second-guessing the inputter whose attempts may well be valid, but look odd in plain discrete standalone terms. Thanks for any suggestions along these lines.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2016
Commented:
I would always assume the worst from a user. That doesn't mean sanitize the input at entry because if you 'ban' certain characters they might tell you the gui is 'broken'. You can always remove garbage after entry
Yes, your observations are, naturally, correct.

Part of the "problem" (which I admit to having created myself of course), is that the post-entry correction route - which would be the best path - is complicated by the fact that I have a Listener on the input field which reflects the lexical correctness of the input, marrying it to the number of words that have been entered. So, if the user inputs "Hello World", the Listener picks up on the fact that there are two words - 'in real time' as it were. This is arrived at from a split() on the text, based on space characters. So if the user inadvertently inputs more than one space between words, (terms), the Listener concludes more than the correct number of words. Of course, a later correction can be made, but it is the on-the-spot word count that I'm hoping to reflect more accurately, if that makes any sense.
Top Expert 2016

Commented:
Well splitting on the pattern " +" would obviate it if it's being done by regex
Rowby Goren Makes an Impact on Screen and Online

Learn about longtime user Rowby Goren and his great contributions to the site. We explore his method for posing questions that are likely to yield a solution, and take a look at how his career transformed from a Hollywood writer to a website entrepreneur.

I had that in there. But I have perhaps overlaid it with some other process. Will check again.
I think I'm there with it now. Not entirely just a question of removing white space, but I have a working result - albeit in an ugly exception handler. But I can work on that angle.
Top Expert 2016

Commented:
:)

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial