我有如下网址的页面源信息:http://feeds.feedburner.com/thecarconnection/porsche
<description><img src='http://images.thecarconnection.com/tmb/2013-porsche-panamera-platinum-edition_100405984_t.gif'/> Best known for its legendary two-door sports cars, Porsche has branched out to the SUV and sedan fields in recent years. The company's first four-door car, the Porsche Panamera, has set tongues wagging and hearts yearning with its blend of unconventional style and blazing performance. While the Panamera range spans a broad scope, it competes...<img src="http://feeds.feedburner.com/~r/thecarconnection/porsche/~4/_LggPvmEzJ4" height="1" width="1"/></description>我想从描述中删除'img src='http://images.thecarconnection.com/tmb/2013-porsche-panamera-platinum-edition_100405984_t.gif'‘链接。我使用MWFeedParser作为描述的一部分来解析URL。对移除描述标签中的链接有什么建议吗?
发布于 2013-01-29 22:57:58
您可以尝试使用此代码片段,使用NSRegularExpression
NSString *description = ...;
NSError *error = NULL;
NSRegularExpression *regex = [NSRegularExpression
regularExpressionWithPattern:@"\\<img src='[^']*' */\\>"
options:NSRegularExpressionCaseInsensitive error:&error];
NSString *modifiedDescription = [regex stringByReplacingMatchesInString:description
options:0
range:NSMakeRange(0, [description length])
withTemplate:@""];https://stackoverflow.com/questions/14514508
复制相似问题