small medium large xlarge

21 Aug 2009, 04:15
Christopher Tysh (49 posts)

I’ve got some HTML coming in that contains some ` <DIV>tags. I would like to remove these <DIV> tags from the HTML, but the problem is that some of the <DIV> tags have classes or ids defined in them. I can replace the <DIV` portion of the tag, but since there is no wildcard allowed, I don’t know how to get rid of all these tags.

Basically what I would like to do: ` mystring = [mystring stringByReplacingOccurrencesOfString:@”<div*>” withString:@””]; `

Any ideas would be great.

21 Aug 2009, 14:36
Christopher Tysh (49 posts)

I’m looking at NSPredicate but not sure how / if I can work with this to make it do what I’m trying to acheive.

21 Aug 2009, 17:37
Bill Dudney (916 posts)

Hi Christopher,

You have to search for <div then when its found find > and nuke everything between them.

indexOfCharacter: or something like that would be the way to go.

Good luck!

21 Aug 2009, 18:38
Christopher Tysh (49 posts)

I found a couple of functions online that might work out. If these don’t work I’m going to try something with finding the Range of the characters and then removing characters in that rage, or keep hacking at NSScanner.

22 Aug 2009, 23:53
Christopher Tysh (49 posts)

So you guys know, the code on this page

works to remove the HTML Tags from an NSString.