0

Contains() with FORMSOF() is great for trying to capture the user's intent while searching, but is there any way to highlight the matches.

If I search for "said", it might return texts containing "says, say, spoke" etc. Is there a way a way I can highlight the match in the results, or Is there a way to surround the match with underscores? So I might get

She _says_ yes.
I _say_ my name.
We _spoke_ for hours but he didn't _say_ much.

I've considered an after-the-fact (client-side) regex solution that would esentially remove commmon word endings like (e|ed|es|s|ing) and then look for my results with with all those options (so bakes would become bak and then I'd search for bak[a-z]?(s|d|es|ed|ing) and that works okay for words like that, but there's a whole lot of cases where the past tenses don't follow that formula, like speak vs spoke and spake.

Regular Jo
  • 5,190
  • 3
  • 25
  • 47
  • It would be ideal to do this one within the business logic or while displaying on web/view. – Bhasyakarulu Kottakota Jan 29 '15 at 23:42
  • Well, I don't think that there's a way to retrieve the match positions so it feels like, for precise matching, I'd have to have SQL highlight the matches (if there's a way, the point of the question) because a client-side regex simply cannot catch many of the results. – Regular Jo Jan 29 '15 at 23:46

1 Answers1

0

There are two SQL Server functions that can help you with this:

The Soundex function help you to compare similar words. and the difference function helps you to evaluate the difference.