I need a little kickstart on regex on iphone. I basically have a date list in a private MediaWiki in the form *185 BC: SOME EVENT HERE
*2001: SOME OTHER EVENT MUCH LATER
Now I want to parse this into an Object that has an NSDate property and a -say-NSString property. I still have this: (rawContentString contains the mediawiki page syntax)
NSString* regexString =@ "\\*( *[0-9]{1,}.*): (.*)"; NSRegularExpressionOptions options = NSRegularExpressionCaseInsensitive; NSError* error = NULL; NSRegularExpression* regex = [NSRegularExpression regularExpressionWithPattern:regexString options:options error:&error]; if (error) { NSLog(@"%@", [error description]); } NSArray* results = [regex matchesInString:rawContentString options:0 range:NSMakeRange(0, [rawContentString length])]; for (NSTextCheckingResult* result in results) { NSString* resultString = [rawContentString substringWithRange:result.range]; NSLog(@"%@",resultString); }
Unfortunately, I think the regex doesn't work the way I hope, and I don't know how to write down an agreed date and text. Any help would be great. By the way: is there any way to compile a regular expression for MediaWiki syntax somewhere?
Thanks in advance Heiko *
source share