0

我有以下网址的页面源信息,如下所示:http: //feeds.feedburner.com/thecarconnection/porsche

 <description>&lt;img src='http://images.thecarconnection.com/tmb/2013-porsche-panamera-platinum-edition_100405984_t.gif'/&gt; 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...&lt;img src="http://feeds.feedburner.com/~r/thecarconnection/porsche/~4/_LggPvmEzJ4" height="1" width="1"/&gt;</description>

我想从描述中删除 'img src='http://images.thecarconnection.com/tmb/2013-porsche-panamera-platinum-edition_100405984_t.gif'' 链接。我正在使用 MWFeedParser 将 URL 解析为描述的一部分。关于删除描述标签中链接的方法有什么建议吗?

4

1 回答 1

1

您可以尝试使用此代码段,使用NSRegularExpression

NSString *description = ...;
NSError *error = NULL;

NSRegularExpression *regex = [NSRegularExpression
        regularExpressionWithPattern:@"\\&lt;img src='[^']*' */\\&gt;"
        options:NSRegularExpressionCaseInsensitive error:&error];

NSString *modifiedDescription = [regex stringByReplacingMatchesInString:description
           options:0
           range:NSMakeRange(0, [description length])
           withTemplate:@""];
于 2013-01-29T14:57:58.417 回答