I'm trying to get some info out of a document. I'm trying to match the info I need with regex, which matches 3 numbers within a string. It works fine, but it only matches the first occurance. I need it to match an unlimited number of times because I don't know how many times this string will occur.
NSString *regex = @"String containing data:(\\d+) and more data:(\\d+) and so on";
NSArray *captures = [document captureComponentsMatchedByRegex:regex];
for(NSString *match in captures){
NSLog(@"%@",match);
}
The above code prints out 3 strings - The entire string, the first data and the second data. All good, but now I need it to keep searching the document, because similar strings will occur n times.
How do I do this? And is there any way to group the matches into an array for each string or something like that?