views:

141

answers:

3

What is the best way to search strings for something like forum? i seen horrible string search and typically get worse the more strings you use rather then better.

I also may implement a title search so if the way to search title that is better then a body of string i'd love to hear that too

+4  A: 

Take a look at using Lucene (Java) (or Lucene.Net) for full text search. Lucene is a text-mining API that allows you to index and search documents by title, text, author, etc. I've used a Ruby port of Lucene (Ferret or acts_as_ferret) to index a specialized mailing list and found that it works very well.

tvanfosson
A: 

Not sure what you mean exactly by "Forum", but Regular Expressions may be a good place to start.

Too general?

TJB
+3  A: 

I would in most cases suggest using the "Boyer Moore" string search algorithm.

You can read about it on wikipedia:

http://en.wikipedia.org/wiki/Boyer%E2%80%93Moore_string_search_algorithm

There's also a lot of example code around to look at, if you're not interested in trying to implement it yourself.

If performance isn't important at all, I would agree with using regular expressions.

sharkin