小程序怎么过滤掉html标签?
1 回答
慕容708150
TA贡献1831条经验 获得超4个赞
</span></span></p>";
[self flattenHTML:str];
}
- (NSString *)flattenHTML:(NSString *)html {
NSScanner *theScanner;
NSString *text = nil;
theScanner = [NSScanner scannerWithString:html];
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:@""];
} // while //
NSLog(@"-----===%@",html);
return html;
}
- 1 回答
- 0 关注
- 583 浏览
添加回答
举报
0/150
提交
取消