我有一种方法可以用来从 NSString 中删除 HTML 标签(我用它创建了一个类别):
-(NSString *) stringByStrippingHTML {
NSRange r;
NSString *s = [[self copy] autorelease];
while ((r = [s rangeOfString:@"<[^>]+>" options:NSRegularExpressionSearch]).location != NSNotFound)
s = [s stringByReplacingCharactersInRange:r withString:@""];
return s;
}
问题是我想删除除标签之外的所有 HTML 标签<br>
,我能做到吗?