NSString * str = @"http://yourhostaa/index.php?path=hellow/index&id=893&cid=123;http://yourhostbb/index.php?path=hellow/index&id=888&cid=456";
NSString * patton = @"http://([^/]+)/index.php\\?path=hellow/index&id=(\\d+)&cid=(\\d+)";
NSArray *array = nil;
NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:patton options:NSRegularExpressionCaseInsensitive error:nil];
array = [regex matchesInString:str options:0 range:NSMakeRange(0, [str length])];
NSString *str1 = nil;
for (NSTextCheckingResult* b in array)
{
for(int i=0;i<b.numberOfRanges;i++){
str1 = [str substringWithRange:[b rangeAtIndex:i]];
NSLog(@"str -> %@",str1);
}
}
使用NSRegularExpression 提取匹配内容。