stiefels.net Just another WordPress weblog

10Sep/070

Full Perl-Compatible Regular Expressions in Objective-C

A few months ago I wrote about a mechanism which allowed simple [Pattern Matching with NSPredicate](http://www.stiefels.net/2007/01/24/regular-expressions-for-nsstring/).
Although it is a good method to check if a string matches a Regular Expression it lacks a lot of features you normally expect while you're doing something with Regular Expressions, such as capturing subpatterns or doing search and replace.

[Philip Hazel](http://www.uit.co.uk/exim-book/author-bio.htm) (who also wrote my favourite SMTP server, [Exim](http://www.exim.org) created a library called [PCRE (Perl-Compatible Regular Expressions)](http://www.pcre.org) a long time ago which implements the Regular Expression syntax used in [Perl](http://www.uit.co.uk/exim-book/author-bio.htm) (sometimes I miss that time) for the C Programming Language.
While PCRE is great for doing Regular Expressions in C, it's usage with Objective-C is some kind of cumbersome as NSString objects must be converted to plain C strings and back again.

But recently John Engelhart released an alpha version of his PCRE-based [RegexKit framework](http://regexkit.sourceforge.net), which provides a sweet object-oriented interface to Regular Expressions. It looks very mature and there is also a [very good documentation](http://regexkit.sourceforge.net/Documentation/index.html) available.

Thank you very much, John!

Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


No trackbacks yet.