[thelist] Highlighting a keyword within posting retrieved

Hassan Schroeder hassan.schroeder at gmail.com
Sat Apr 21 23:51:17 CDT 2007


On 4/21/07, klute <soundres9 at yahoo.com> wrote:

>  Regex may be the way to go
> but it comes with this challenge: I can't really do a
> straight search and replace of the actual keyword with
> SPAN since that keyword can be a part of another
> (potentially unrelated) word.

Um, "part of"? -- I don't think MySQL text search handles that...

It depends on your exact requirements, of course, but your examples
all look like a non-word character -- \W -- followed by your keyword
followed by another non-word character; that's a single replacement.

> I wish there was a regex library or something that
> does what a search against a fulltext index does in
> MySQL.

The only real problem I can see is with stemming, which -- if I recall
correctly, and it's been a while since I've done this -- is a bit of a weak
point with MySQL's text search, anyway. Grain of salt, etc.

I mean, even Lucene doesn't have a built-in stemmer, and that's just
nuts. But since I haven't volunteered to fix it, I can't complain, can I? :-)

In any case, I'd just try a \Wkeyword\W replacement and see how many
cases that hits.

FWIW,
-- 
Hassan Schroeder ------------------------ hassan.schroeder at gmail.com



More information about the thelist mailing list