Fastest String Search

KeysCoder

Member
Joined
Apr 10, 2006
Messages
18
Location
Florida Keys
Programming Experience
3-5
I'm working on an application which needs to search through every word in a rich text box and match individual words and phrases to those in a database. I'm thinking it would be faster to save the text to a string class first and search through it rather than through the rich text box itself.

Am I right? How about the StringBuilder class? I know it's very fast for manipulating a string but would it be any faster (than the plain string class) for searches?
 
You don't search a RichTextBox. You search its Text property, which is already a String object. If you're looking for whole words then you may as well just use String.IndexOf or else the Regex class can find all occurrences in one method call.
 
words and phrases?

hmm.. so a text box with 4 words in has these combinations:
a
b
c
d
ab
bc
cd
abc
bcd
abcd



hmm... i think your search is going to be very long if you include phrases...
 
Back
Top