iOS Objective-C 去除富文本html标签

发布于 2017-03-13 / iOS / 0条评论 / 1,614浏览

Code

/**
 * 去掉所有的html标签
 */
- (NSString *)getTextWithHtmlString:(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;
}
评论
站长统计