猿问
下载APP

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

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

倚天杖
浏览 1574回答 1
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;}
打开App,查看更多内容
随时随地看视频慕课网APP
我要回答