NSString with some html tags, how can I search for <img> tag and get the content of url
问题 I have a NSString with some html tags, how can I search for tag and get the content of url? I'm not sure if I must use Hpple or a simple Regex expression. In both cases can I have some example? 回答1: One way to do this is using NSScanner. See this example: NSString *url = nil; NSString *htmlString = ... NSScanner *theScanner = [NSScanner scannerWithString:htmlString]; // find start of IMG tag [theScanner scanUpToString:@"<img" intoString:nil]; if (![theScanner isAtEnd]) { [theScanner