-(NSString *)cleanHTML:(NSString *)html
{
NSScanner * scanner = [NSScanner scannerWithString:html];
NSString * text = nil;
while([scanner isAtEnd]==NO)
{
[scanner scanUpToString:@"<" intoString:nil];
[scanner scanUpToString:@">" intoString:&text];
html = [html stringByReplacingOccurrencesOfString:[NSString stringWithFormat:@"%@>",text] withString:@""];
}
return html;
}
上面方法可行,但是有时候会发现没有效果
将 "<" 修改为"<" (不要漏掉分号)
将 ''>' 修改为 ">" (不要漏掉分号)
更多关于NSScanner请查看 -->>>Flying_Einstein 的 NSScanner 详解
网友评论