Re: Text Searching system...
Re: Text Searching system...
- Subject: Re: Text Searching system...
- From: Jens Alfke <email@hidden>
- Date: Mon, 14 Sep 2009 10:18:08 -0700
On Sep 11, 2009, at 4:47 AM, Farooq zaman wrote:
I want to develop a text searching system for my application. This
system should search for a search expressions in all files present
is a particular project directory. Can anybody tell me what COCOA
classes used for text searching?
There isn't anything in Cocoa that will search through files. You
could read a file into memory using +[NSString
stringWithContentsOfFile:usedEncoding:error] and then use -[NSString
rangeOfString:] to look for string you want to match, but this will be
really inefficient, especially with large files or large numbers of
files.
If you need to search for general patterns, not just literals, look
into RegexKitLite.
Optimally you'd want to open each file as a stream and read through it
for the pattern. (You might want to read up on efficient string-search
algorithms like Boyer-Moore or Rabin-Karp.) You can do this using
standard C or POSIX file APIs.
—Jens_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden