Re: Regular Expressions?
Re: Regular Expressions?
- Subject: Re: Regular Expressions?
- From: David Hoerl <email@hidden>
- Date: Fri, 06 Jun 2008 12:16:36 -0400
dream cat7 wrote:
> I agree that to be able to use that syntax is highly desirable, and
indeed missing from all the cocoa libraries that I have looked at. One
way would be a category addition to NSString class, which would call
the perl -pe 's/\b(.*?)/\u\L$1/g' for you and return the result as an
NSString...
But unfortunately nobody has come up that type of an extension to
NSString yet.
Or are there and c-libraries that will accept this s//// syntax ?
Well, Terry Jones wrote a routine called "strsed" in 1990 that in
fact does this:
http://www.jones.tc/personal/odds-and-ends.html
It was loosely modeled on sed(1). It's a C routine that has this format:
str = strsed(string, command, option);
The strings is something like "Hello world". The command is of the form:
s/search/replace/ or g/search/replace/
The "s" version finds the first match and replaces it. The "g"
version finds and replaces every occurrence. It uses the regex(3)
library.
That's the good part. The bad part is that uses the older simpler
regex capability. I'm in the process of modernizing this code to use
the POSIX mode of regex(3), and hope to have it done next week. I
will eventually put it on my not-yet-done web site and support it
(maybe a small ObjC class for use with the icu library too).
In the mean time, email me if you want version 1 (couple of days). It
will be released with a very permissive license as the base code was
totally open source.
David
_______________________________________________
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