我有以下网址的网页来源信息,如下所示: 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。有关删除描述标记内链接的方法的任何建议吗?
答案 0 :(得分:1)
您可以使用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:@""];