顺便附上一个移除html标签的方法
-(NSString *)filterHTML:(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:@""]
}
//NSString * regEx = @"<([^>]*)>"
//html = [html stringByReplacingOccurrencesOfString:regEx withString:@""]
return html
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)