ios 正则获取img 里的 src
NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://wiki.mbalib.com/wiki/2015%E5%B9%B4%E3%80%8A%E7%A6%8F%E5%B8%83%E6%96%AF%E3%80%8B%E4%B8%AD%E5%9B%BD%E6%85%88%E5%96%84%E6%A6%9C"]];
NSString *htmlString = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
NSString *regulaStr = @"<\\s*img\\s+[^>]*?src\\s*=\\s*[\'\"](.*?)[\'\"]\\s*(alt=[\'\"](.*?)[\'\"])?[^>]*?\\/?\\s*>";
// NSString *regulaStr = @"<\\s*img\\s+";
NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:regulaStr
options:NSRegularExpressionCaseInsensitive
error:nil];
NSArray *arrayOfAllMatches = [regex matchesInString:htmlString options:0 range:NSMakeRange(0, [htmlString length])];
for (NSTextCheckingResult *match in arrayOfAllMatches)
{
NSRange range = match.range;
range.location = 1;
NSString* substringForMatch = [htmlString substringWithRange:match.range];
NSLog(@"=== substringForMatch %@", substringForMatch);
// 提取 src =》
NSString* group1 = [htmlString substringWithRange:[match rangeAtIndex:1]];
}