美文网首页
IOS使用正则表达式去掉html中的标签元素,获得纯文本

IOS使用正则表达式去掉html中的标签元素,获得纯文本

作者: ArsonQ | 来源:发表于2016-08-23 23:07 被阅读0次
//正则去除网络标签
-(NSString *)getZZwithString:(NSString *)string{
    NSRegularExpression *regularExpretion=[NSRegularExpression regularExpressionWithPattern:@"<[^>]*>|\n|&nbsp"
                                                                                    options:0
                                                                                      error:nil];
    string=[regularExpretion stringByReplacingMatchesInString:string options:NSMatchingReportProgress range:NSMakeRange(0, string.length) withTemplate:@""];
    return string;
}

相关文章

网友评论

      本文标题:IOS使用正则表达式去掉html中的标签元素,获得纯文本

      本文链接:https://www.haomeiwen.com/subject/mlmnsttx.html