Syntax Highlighting for NSTextView with flex
Implementing syntax highlighting can be a painful task. Lots of regular expressions and thinking may be required to master this.
On the search for an easy way to implement a syntax highlighting mechanism for NSTextView I found an easy and fast (regarding runtime) way to do this. By using flex (a tool with its roots in the 1970's) defining the rules of what should be highlighted makes it a lot more easier and structured.
flex is the GNU version of lex, the lexical analyzer generator (Buzzword jackpot!) developed by Eric Schmidt and Mike Lesk in 1975. By defining some rules (mainly regular expressions) it generates a C program which allows us to scan through a text and do something with the text, e.g. divide it into tokens. Tokens are chunks of characters with a special meaning (as defined in our rules). Confused? Read on, this concept will become very clear soon.
In this article I want to show you how we can use this ancient but very powerful tool to implement a basic syntax highlighting within a NSTextView.
Late Night Cocoa Podcast

[Late Night Cocoa](http://www.latenightcocoa.com) is a great podcast about Cocoa and Mac OS X development and if you're interested in these topics and haven't heard about Late Night Cocoa yet, [fire up your iTunes](http://phobos.apple.com/WebObjects/MZStore.woa/wa/viewPodcast?id=213023580)
and give it a try.
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.
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.

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!
Practice Makes Perfect
How can you be perfect (or at least good) at something if you don't practice? I think, not at all. Especially when it comes to software development beeing perfect without practice is hardly possible.
So, have some practice! To get some help with that, you should visit [Chris Forsythe's website](http://www.brok3n.org/).
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).
Weblogs About Mac OS X Development
If you're a mac developer you certainly subscribed some weblogs about Cocoa development with OS X.
[Scott Stevenson](http://www.theocacao.com) created a nice new website called [Cocoa Blogs](http://www.cocoablogs.com). It bundles weblogs and tutorials from well known OS X developers.
The place to go for your daily Cocoa dose.
Great idea and very cool design.
Thank you, Scott.
New Code Snippet: STNKeychainAccess
A few minutes ago I updated the [projects page](/projects).
I added a subcategory *Little Helpers* in which I will publish some code snippets for different purposes.
The first one is an Objective-C class for accessing the keychain service in Mac OS X: [STNKeychainAccess](/projects/stnkeychainaccess).
In the downloadable zip-file you can find a Xcode project with a small cocoa application which shows how this class can be used in your application.
Have fun!