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!

3Apr/070

Over 200 Downloads of RegexTester

I must admit, I am a little surprised that my teeny tiny little software [RegexTester](/projects/regextester) was downloaded over 200 times in just five days (according to [macupdate.com](http://www.macupdate.com/info.php/id/24535)). I am very pleased and I'd like to get some reviews and opinions. :)

Tagged as: , No Comments
14Mar/070

New Little Helper: RegexTester

A few week ago I [wrote](/2007/01/24/regular-expressions-for-nsstring/) about how the regular expression mechanism in NSPredicate can be used to validate strings.
I created a small application which exactly does that - validating strings.

RegexTester Screenshot

It's called RegexTester (yeah, innovative name, I know) and is intended to be a help for developers who have to formulate regular expressions.
More information can be found [here](/projects/regextester).

Have fun!

Tagged as: , No Comments
24Jan/0713

Regular Expressions for NSString

Last weekend I was looking for different options to validate NSString objects against some regular expressions.
While there are some 3rd party classes for doing regular expressions in Cocoa and wrappers for Perl/PCRE there is a way to do that without external software. The magic word is called [NSPredicate](http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSPredicate_Class/Reference/NSPredicate.html).
This approach may perhaps not be obvious because there is (at this time) no direct documentation or hint in the [ADC documentation](http://developer.apple.com).