例如后台返回如此数据让你截取:
这时你就需要解析当前content了
方法 1
方法 2
//对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:@""];
html = [html stringByReplacingOccurrencesOfString:@" " withString:@""];
}
NSString * regEx = @"<([^>]*)>";
html = [html stringByReplacingOccurrencesOfString:regEx withString:@""];
return html;
}
动手试试吧