I am trying to parse a string using NSRegularExpression so that I can extract several strings in between predefined phrases:
NSString* theString = @"the date is February 1st 2000 the place is Los Angeles California the people are Peter Smith and Jon Muir";
NSString *pattern = @"(?:the date is )(.*?)(?: the place is )(.*?)(?: the people are )(.*?)";
NSError *error = nil;
NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:pattern options:NSRegularExpressionCaseInsensitive error:&error];
NSArray* matches = [regex matchesInString:theString options:0 range:NSMakeRange(0, theString.length)];
I am expecting to get 3 matches:
February 1st 2000 Los Angeles California Peter Smith and Jon Muir
However it looks like I am not putting the regex groups properly. Any suggestion?