Blog

Crash Reporter

Aug 22, 2006 — Whitney Young

I've abstracted Adium's Crash Reporter and modified it a bit. It's pretty nice.

Here's a screenshot:
Crash Reporter

Check it out here:
svn://fadingred.org/crashreporter/trunk

Read More...

No Comments Tags: Cocoa, Framework, Open Source, Software

Objective-C (Cocoa) Regex

Aug 4, 2006 — Whitney Young

It has always bothered me that Cocoa doesn't have Regular Expressions built in. Using PCRE 6.7, I've created a small Cocoa Framework that does Regular Expressions. I know there's the AGRegex that's up on sourceforge, but I decided to take my crack at making something that might be a little different. It's not complete yet, but I figured I'd write about it since I just created a subversion repository for it.

Here are the basics:

  • There's a PCRegex object
  • All matching is done via calls on strings (not on the Regex object)

I chose to call methods on the strings instead of the regex objects because this is a little more like all other object oriented regular expression implementations and because I think it makes more sense that way.

Creating a regular expression is easy as:
PCRegex *regex = [PCRegex regexWithPattern:@"pattern"];

Matching regular expressions against strings is easy, too. With the previous regular expression defined:

#import <ObjCRegex/ObjCRegex.h>
...
[@"This is the string that I want to match" match:regex];
[@"This string will match because it contains the word pattern" match:regex];

With connivence methods everything is extremely simple:

#import <ObjCRegex/ObjCRegex.h>
...
[@"This is the string that I want to match" matchPattern:@"pattern"];
[@"This is the string that I want to match" matchPattern:@"str.*"];

Of course if you want something more powerful, you're wondering what I did to deal with backreferences. Again, it's pretty simple. Here's an example:

#import <ObjCRegex/ObjCRegex.h>
...
NSArray *backrefArray;
PCRegex *regex = [PCRegex regexWithPattern:@"([^ ]*) ([^ ]*)"];
[@"first second third" match:regex backreferences:backrefArray];
NSString *first_match = [[backrefArray objectAtIndex:1] string];
NSString *second_match = [[backrefArray objectAtIndex:2] string];

Like many other implementations, the 0th item in the backreference array is the fully matched string, so in the previous example it would be @"first second".

There are some things that are incomplete and/or you should know before you get excited about using it:

  • There's no support for named backreference (yet)
  • UTF-8 isn't supported (thought PCRE dose support it, so if someone wants to add support, that'd be great)
  • I've done little testing with it, though it seems to work just fine
  • GPL license as always

So if you're still reading, you may be interested in checking out the code which can be done via:
svn co svn://fadingred.org/objcregex/trunk objcregex

Enjoy!

2 Comments Tags: Cocoa, Code, Objective-C, Regex

Website updates

Aug 2, 2006 — Whitney Young

I've changed my site yet again. The reason I changed it this time was pretty much just to get Trac integrated into all of my projects. Here's what's changed:

  • Interface
    • New design
    • Cleaner XHTML
    • Seamless Trac integration
  • Backend
    • Object oriented PHP integrated with MySQL
    • Moved all lingering data off the disk and into MySQL
    • Much faster (because of the above)
    • Custom Trac plugins to work with InterTrac

I'm fairly pleased with the way everything turned out in terms of design, usability, and speed. Having Trac should simplify my life and the life of others as well. No more clunky, unsearchable, support pages.

No Comments Tags: Webserver