Please consider the following:
NSString *myText = @"mary had a little lamb";
NSString *regexString = @"mary(.*?)little";
for(NSString *match in [myText captureComponentsMatchedByRegex:regexString]){
NSLog(@"%@",match);
}
This will output to the console two things:
1) "mary had a little" 2) "had a"
What I want is just the 2nd bit of information "had a". Is there is a way of matching a string and returning just the inner part?
I'm fairly new to Objective C, this feels a rather trivial question yet I can't find a less messy way of doing this than incrementing an integer in the for loop and on the second iteration storing the "had a" in an NSString.