[ANN] RegexKit - An Objective-C Framework for Regular Expressions Using the PCRE Library
[ANN] RegexKit - An Objective-C Framework for Regular Expressions Using the PCRE Library
- Subject: [ANN] RegexKit - An Objective-C Framework for Regular Expressions Using the PCRE Library
- From: John Engelhart <email@hidden>
- Date: Sat, 1 Sep 2007 12:49:15 -0700 (PDT)
Announcing RegexKit - A framework for regular
expressions using the PCRE library.
At the point in time, this framework is being made
available as an ALPHA test release to solicit
developer comments. While there are no known major
issues with the framework, it is the first time it is
being made available to the public.
The project is hosted at sourceforge, and you can
access it via:
http://regexkit.sourceforge.net/
The framework documentation is available at:
http://regexkit.sourceforge.net/Documentation
The sourceforge project page is:
http://sourceforge.net/projects/regexkit/
While the API documentation is largely complete,
documentation for a final, end-user distribution is
still in flux. There is no sample "double-click and
go" example Xcode project with this release, although
one is planned. Right now I would appreciate feedback
from experienced cocoa developers regarding the API
and usability of the framework.
Some highlights:
o BSD license for the framework. The PCRE library has
a BSD license as well.
o Uses PCRE 7.3, the latest release as of this
posting.
o Mac OS X 10.4 or later required.
o Caches compiled regular expressions for speed.
o Specifically designed to be multithreading safe.
o Designed to be fast and light-weight. Uses the stack
extensively for temporary items and work, rarely
resorts to malloc().
o Not just a wrapper around PCRE, but extends by
category NSArray, NSDictionary, NSSet, and especially
NSString.
o It's documented. No, I'm not kidding, it's actually
documented. Documentation style is the same, familiar
style as Apples documentation.
As an example of that's possible with the NSString
additions, consider the following: Find, extract, and
convert to an unsigned int a hex value from a
NSString. Here's how you can do it with RegexKit:
unsigned int hexValue = 0;
[@"Conversion color: 0xFF0000, Order: 1"
getCapturesWithRegexAndReferences:@"color:
(0x[0-9a-fA-F]+)", @"${1:%x}", &hexValue, NULL];
// hexValue == 16711680 || 0xFF0000
getCapturesWithRegexAndReferences: allows you to
easily match a capture subpattern from a regular
expression and perform a scanf() style conversion.
Also note that there is no need to create a regular
expression object, the framework will automatically
convert NSString objects to RKRegex objects for you.
In fact, getCapturesWithRegexAndReferences: will
accept either an instantiated RKRegex object, or a
NSString which it will convert.
You can also create new strings with references to
regular expression matched text:
NSString *newString = [@"Doe, John"
stringByMatching:@"(?<last>\\S+),\\s*(?<first>\\S+)"
withReferenceString:@"Dear ${first} ${last},\n\nHow
are you today, ${first}?"];
/*
newString ==
Dear John Doe,
How are you today, John?
*/
There are similar search and replace methods as well.
With this alpha release, I'm looking for comments from
objective-c cocoa developers regarding the API. Any
other comments are welcome as well. I'm in the final
push to get a "1.0" general release done, so I'd like
to freeze the features of the framework and
concentrate on getting a polished release out the
door. As I mentioned, there's some conflicting
information in the current release regarding
first-time user related information, such as
references to an old "cli_test*" target/code. I don't
expect any experienced cocoa developer to be thrown
off, though. The documentation regarding adding the
framework to your project (should?) be just fine, just
no examples yet.
____________________________________________________________________________________
Choose the right car based on your needs. Check out Yahoo! Autos new Car Finder tool.
http://autos.yahoo.com/carfinder/
_______________________________________________
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