为了账号安全,请及时绑定邮箱和手机立即绑定

请问小程序怎么过滤掉html标签?

/ 猿问

请问小程序怎么过滤掉html标签?

倚天杖 2018-07-15 10:08:38

小程序怎么过滤掉html标签?

查看完整描述

1 回答

?
MYYA

</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;
}

查看完整回答
反对 回复 2018-07-29

添加回答

回复

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信