A few months ago I wrote about a mechanism which allowed simple Pattern Matching with NSPredicate.
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 (who also wrote my favourite SMTP server, Exim created a library called PCRE (Perl-Compatible Regular Expressions) a long time ago which implements the Regular Expression syntax used in Perl (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, which provides a sweet object-oriented interface to Regular Expressions. It looks very mature and there is also a very good documentation available.
Thank you very much, John!
Technorati Tags: objective-c, regular expressions

0 Responses to “Full Perl-Compatible Regular Expressions in Objective-C”