views:

184

answers:

4

I am trying to write program its like a simple search engine, in this program the user is supposed to enter a search keyword into an edit box and then he can click the search button, and the program is supposed to open a specific text file from the directory and find a matching word to that keyword in this text file. I am using Delphi 2007. thank you

A: 

Basically you need to find a string in another string. Take a look at this algorithm: http://en.wikipedia.org/wiki/Knuth-Morris-Pratt_algorithm

stribika
A: 

I have written something similar in C# - Searcharoo.net - you can download the source code from there.

What might be more useful, though, are the articles that I wrote describing how it works... This description of how Version 1 might be of some use - although I'm probably biased since I wrote it (back in 2004).

Your question is pretty open so I'm not sure if this will help - particularly since I don't know Delphi and how different it is to C# - but hope it helps...

CraigD
+1  A: 

If you are on a unix system, send a call to grep. If you are on a windows system, install grep for windows.

hashable
Actually, Delphi comes with grep...
Jeroen Pluimers
+1  A: 

You might want to look at the source code for the open source project GExperts. It contains a text search engine (grep) that works very well.

skamradt