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 > Regular Expressions in Obj-C...can't get anything to work

Regular Expressions in Obj-C...can't get anything to work
Thread Tools
OliverTwist
Fresh-Faced Recruit
Join Date: Aug 2007
Status: Offline
May 2, 2008 , 02:08 PM
 
I'm making an iPhone app, and I need to do a search-and-replace regex on a string. I've tried OmniFoundation, RegexKit, ObjPCRE, and many other third-party regex libraries, and none of them work for me. Omni results in dozens of errors when I compile, RegexKit results in one error ("cannot find Cocoa/Cocoa.h"), and ObjPCRE results in the following three errors:
"_pcre_free", referenced from:
_pcre_free$non_lazy_ptr in objpcre.o
"_pcre_compile", referenced from:
-[ObjPCRE compileWithPattern:andOptions:] in objpcre.o
"_pcre_exec", referenced from:
-[ObjPCRE regexMatches:options:startOffset:error:] in objpcre.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
If you know how to get any of these regex libraries working on the iPhone, I would be grateful for the help.
     
Mithras
Professional Poster
Join Date: Oct 1999
Location: :ИOITAↃO⅃
Status: Offline
May 2, 2008 , 10:34 PM
 
I'd go with a straight C library, like PCRE.
     
OliverTwist
Fresh-Faced Recruit
Join Date: Aug 2007
Status: Offline
May 3, 2008 , 03:33 AM
 
That would involve quite a bit of work, including converting all my NSStrings to CStrings and then back again, and with my luck there's no guarantee it would work any better. I'd like to keep it purely Objective-C if possible, for the sake of simplicity in my code.
     
CharlesS
Posting Junkie
Join Date: Dec 2000
Status: Online
May 3, 2008 , 10:31 PM
 
Originally Posted by OliverTwist View Post
That would involve quite a bit of work, including converting all my NSStrings to CStrings and then back again
I'll save you from all that extremely arduous work by providing some lines for you to copy and paste into your project:

const char *myCString = [myNSString UTF8String];
NSString *myNewNSString = [NSString stringWithUTF8String:myCString];

Whew, I think I just threw my back out typing that. I'd better go lie down for a while.

, and with my luck there's no guarantee it would work any better.
Yes there is, because the reason you're getting those link errors is because it's looking for those symbols which are in the C library, and not finding them. A little bird tells me that if you actually had the C library, that would work.

(please forgive my snark: this post was written 100% tongue-in-cheek )

Ticking sound coming from a .pkg package? Don't let the .bom go off! Inspect it first with Pacifist 2.5.2. Macworld - five mice!
     
   
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
vB 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 01:44 AM.
All contents of these forums © 1995-2008 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.6.8 © 2000-2008, Jelsoft Enterprises Ltd., SEO by vBSEO 3.0.0 RC8