RosettaCodeData/Task/Regular-expressions/Objective-C/regular-expressions-5.m

8 lines
400 B
Matlab

for (NSTextCheckingResult *match in [regex matchesInString:str
options:0
range:NSMakeRange(0, [str length])
]) {
// match.range gives the range of the whole match
// [match rangeAtIndex:i] gives the range of the i'th capture group (starting from 1)
}