首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >删除嵌入的媒体URL - iOS的MWFeedParser

删除嵌入的媒体URL - iOS的MWFeedParser
EN

Stack Overflow用户
提问于 2013-01-25 10:42:25
回答 1查看 129关注 0票数 0

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

代码语言:javascript
复制
 <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。对移除描述标签中的链接有什么建议吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-01-29 22:57:58

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

代码语言:javascript
复制
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:@""];
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/14514508

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档