regexkitlite snippets

How to install and use RegexKitLite

Tagged objective-c, regexkitlite, regex, regular expression  Languages objectivec

Install RegexKitLite

First download RegexKitLite.

Configure your project

Double-click the project target under Targets in the Groups & Files sidebar.

Under the Linking header add -licucore to the Other Linker Flags setting.

Setup documentation

In the Xcode menu, open Xcode->Preferences->Documentation. Then click the Add Publisher button.

Add this URL: feed://regexkit.sourceforge.net/RegexKitLiteDocSets.atom

Using RegexKitLite

This will extract the integer that is embedded in a td tag:

NSString *regex = @"<td id\"amount\">(\\d+)</td>";
NSString *body = [[[NSString alloc] initWithData:html encoding: NSASCIIStringEncoding] autorelease];
NSString *amount = [body stringByMatching:regex capture:1];

if ([amount isEqual:@""] == NO) {
    NSLog(@"Amount is %@", amount);
} else {
    NSLog(@"Amount was not found.");
}