Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Using grep or awk for find in Cocoa project

Using grep or awk for find in Cocoa project
Thread Tools
Mac Elite
Join Date: Sep 2000
Location: Eagan, MN
Status: Offline
Reply With Quote
Jun 3, 2001, 06:17 PM
 
I was considering using grep to add a regular-expression find to my Cocoa script editor (for obvious "why write it if a free version already exists" reasons). But, grep seems to only be capable of giving me the byte offsets of lines the containing a match, and the line itself.

Is there a way to force it to output where the matches actually are on the line?

How about using awk?

Or another program?
     
Dedicated MacNNer
Join Date: Apr 2001
Location: San Francisco, USA
Status: Offline
Reply With Quote
Jun 3, 2001, 08:13 PM
 
You might be interested in the OFRegularExpression class provided by the OmniFoundation framework. I haven't used it but it looks pretty straightforward. You can find the Omni frameworks with source code at Omni's web site (seems to be down at the moment).

Let me know if it works!


Edit: Omni's site is back up. http://www.omnigroup.com/community/d...er/sourcecode/

[ 06-03-2001: Message edited by: honeydew ]
     
Senior User
Join Date: Nov 2000
Status: Offline
Reply With Quote
Jun 3, 2001, 09:23 PM
 
What about TextExtras? I think (hope) that's what it's called. I know it has some form of search functionality. I think it's done as an NSFormatter.

Maybe I'll go re-find it..sorry no link or "hard" info.
     
Addicted to MacNN
Join Date: Mar 2000
Location: London, UK
Status: Offline
Reply With Quote
Jun 4, 2001, 01:34 AM
 
I'm pretty sure there's some simple searching functionality in NSString itself, but I'm by no means certain. AHHHHH exams in an hour and a half or so... ahhhhhhhh.
     
Dedicated MacNNer
Join Date: Apr 2001
Location: San Francisco, USA
Status: Offline
Reply With Quote
Jun 4, 2001, 01:44 AM
 
I'm pretty sure there's some simple searching functionality in NSString itself

Yes, but searching is the easy part. Parsing the regular expression syntax and compiling the state machine is difficult. OFRegularExpression does all this for you.
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 12:12 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2