There are a couple of different ways to remove HTML tags
from an NSString
in Cocoa
.
One way is to render the string into an
This is the modernization of m.kocikowski answer which removes whitespaces:
@implementation NSString (StripXMLTags)
- (NSString *)stripXMLTags
{
NSRange r;
NSString *s = [self copy];
while ((r = [s rangeOfString:@"<[^>]+>\\s*" options:NSRegularExpressionSearch]).location != NSNotFound)
s = [s stringByReplacingCharactersInRange:r withString:@""];
return s;
}
@end