Possible Duplicate:
Remove HTML Tags from an NSString on the iPhone
I have a method that i use to remove HTML tags from NSString(i made a category with that):
-(NSString *) stringByStrippingHTML {
NSRange r;
NSString *s = [[self copy] autorelease];
while ((r = [s rangeOfString:@"<[^>]+>" options:NSRegularExpressionSearch]).location != NSNotFound)
s = [s stringByReplacingCharactersInRange:r withString:@""];
return s;
}
The issue is that i want to remove all HTML tags except the <br> tags, can i able to do it?
You can tweak as
First replce
<br/>with*br/*then replace all html tags and then again replace*br/*to<br/>.Or, you can use conditional replacing .. if read tag is
brcontinue else replace.