NSString去掉html标签
2015-12-08 20:52
591 查看
- (NSString *)flattenHTML:(NSString *)html trimWhiteSpace:(BOOL)trim { NSScanner *theScanner = [NSScanner scannerWithString:html]; NSString *text = nil; while ([theScanner isAtEnd] == NO) { // find start of tag [theScanner scanUpToString:@"<" intoString:NULL] ; // find end of tag [theScanner scanUpToString:@">" intoString:&text] ; // replace the found tag with a space //(you can filter multi-spaces out later if you wish) html = [html stringByReplacingOccurrencesOfString: [ NSString stringWithFormat:@"%@>", text] withString:@""]; //NSLog(@"html==%@",html); } html = [html stringByReplacingOccurrencesOfString:@" " withString:@""]; // trim off whitespace return trim ? [html stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] : html; }
相关文章推荐
- NSString去掉html标签
- HTML DOM节点的增删改查
- HTML 介绍
- html name标签命名规范
- 设置overflow:auto表格没有滚动条的解决办法
- HTML实现页面自动跳转的五种方法
- HTML 占满工作区
- HTML页面3秒后自动跳转的三种常见方法
- Html.BeginForm与Ajax.BeginForm
- html页面中阻止用户选中、复制文本,阻止长按保存图片,阻止拖动元素等……
- win10系统ie浏览器不能打开html的解决办法
- HTML 表单和验证事件
-  |"|&|<|>等html字符转义
- HTML学习笔记
- 首页自动生成静态化html
- 关于html居中的几种方式
- html之页面元素印射
- PHP全站过滤提交的HTML代码
- C#正则表达式通过HTML提取网页中的图片src
- mac系统sublime text2安装HTMLPrettify插件 过程及问题解决方案