<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>stiefels.net &#187; regex</title>
	<atom:link href="http://www.stiefels.net/tag/regex/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.stiefels.net</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Sun, 20 Sep 2009 10:39:23 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Full Perl-Compatible Regular Expressions in Objective-C</title>
		<link>http://www.stiefels.net/2007/09/10/full-perl-compatible-regular-expressions-in-objective-c/</link>
		<comments>http://www.stiefels.net/2007/09/10/full-perl-compatible-regular-expressions-in-objective-c/#comments</comments>
		<pubDate>Mon, 10 Sep 2007 19:20:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Mac OS X]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[objective-c]]></category>
		<category><![CDATA[regex]]></category>

		<guid isPermaLink="false">http://www.stiefels.net/2007/09/10/full-perl-compatible-regular-expressions-in-objective-c/</guid>
		<description><![CDATA[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 [...]]]></description>
			<content:encoded><![CDATA[<p>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/).<br />
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.</p>
<p>[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.<br />
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.</p>
<p>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.</p>
<p>Thank you very much, John!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.stiefels.net/2007/09/10/full-perl-compatible-regular-expressions-in-objective-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Over 200 Downloads of RegexTester</title>
		<link>http://www.stiefels.net/2007/04/03/over-200-downloads-of-regextester/</link>
		<comments>http://www.stiefels.net/2007/04/03/over-200-downloads-of-regextester/#comments</comments>
		<pubDate>Tue, 03 Apr 2007 18:33:28 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Mac OS X]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[cocoa]]></category>
		<category><![CDATA[regex]]></category>

		<guid isPermaLink="false">http://www.stiefels.net/2007/04/03/over-200-downloads-of-regextester/</guid>
		<description><![CDATA[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.  
]]></description>
			<content:encoded><![CDATA[<p>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. <img src='http://www.stiefels.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.stiefels.net/2007/04/03/over-200-downloads-of-regextester/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>New Little Helper: RegexTester</title>
		<link>http://www.stiefels.net/2007/03/14/new-little-helper-regextester/</link>
		<comments>http://www.stiefels.net/2007/03/14/new-little-helper-regextester/#comments</comments>
		<pubDate>Wed, 14 Mar 2007 20:02:53 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Mac OS X]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[cocoa]]></category>
		<category><![CDATA[regex]]></category>

		<guid isPermaLink="false">http://www.stiefels.net/2007/03/14/new-little-helper-regextester/</guid>
		<description><![CDATA[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.

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 [...]]]></description>
			<content:encoded><![CDATA[<p>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.<br />
I created a small application which exactly does that - validating strings.</p>
<p><img id="image38" src="http://www.stiefels.net/wp-content/uploads/2007/03/regextesterscreen.png" alt="RegexTester Screenshot" /></p>
<p>It's called RegexTester (yeah, innovative name, I know) and is intended to be a help for developers who have to formulate regular expressions.<br />
More information can be found [here](/projects/regextester).</p>
<p>Have fun!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.stiefels.net/2007/03/14/new-little-helper-regextester/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Regular Expressions for NSString</title>
		<link>http://www.stiefels.net/2007/01/24/regular-expressions-for-nsstring/</link>
		<comments>http://www.stiefels.net/2007/01/24/regular-expressions-for-nsstring/#comments</comments>
		<pubDate>Wed, 24 Jan 2007 22:54:33 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Mac OS X]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[cocoa]]></category>
		<category><![CDATA[regex]]></category>

		<guid isPermaLink="false">http://www.stiefels.net/2007/01/25/regular-expressions-for-nsstring/</guid>
		<description><![CDATA[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 [...]]]></description>
			<content:encoded><![CDATA[<p>Last weekend I was looking for different options to validate NSString objects against some regular expressions.<br />
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).<br />
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).</p>
<p><span id="more-28"></span></p>
<p>NSPredicate was introduced in OS X 10.4 and is mainly used in CoreData applications to specify queries and has therefore also some nice functionality to filter arrays.<br />
But there is also a way to use its built-in regular expression mechanism to validate NSStrings.</p>
<p>Let's say you have a string "Hello World!" and you want to check if there are at least two sequent l's in it. The regular expression would be: ".\*l{2,}.\*" (without quotes).<br />
Note, that there is a dot followed by an asterisk (which means "zero or more characters") at the beginning and at the end of the actual expression (l{2,}). This is necessary because (unlike the regular expressions in Perl) the "interpolated length" of the regular expression must be at least the same as the length of the string to test to (I don't know why but that's what I found out during my tests).</p>
<p>In your Cocoa application this test would look like this:</p>
<p>    NSString *mystring = @"Hello World!";<br />
    NSString *regex = @".*l{2,}.*";</p>
<p>    NSPredicate *regextest = [NSPredicate<br />
                             predicateWithFormat:@"SELF MATCHES %@", regex];</p>
<p>    if ([regextest evaluateWithObject:mystring] == YES) {<br />
        NSLog(@"Match!");<br />
    } else {<br />
        NSLog(@"No match!");<br />
    }</p>
<p>This is easy, isn't it?<br />
All you have to do is to create a NSPredicate object with the predicate "SELF MATCHES" followed by a regular expression and call its "evaluateWithObject:" method with your string you want to validate. It returns YES if the string matches your regular expression and NO if it does not.</p>
<p>If you don't like this approach or if you don't want your application to require OS X 10.4 you can find some other solutions and documentation regarding regular expressions in Cocoa at [this webpage](http://www.cocoadev.com/index.pl?RegularExpressions).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.stiefels.net/2007/01/24/regular-expressions-for-nsstring/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
	</channel>
</rss>
