Remove HTML Tags from an NSString on the iPhone

前端 未结 22 1485
心在旅途
心在旅途 2020-11-22 10:02

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

22条回答
  •  天涯浪人
    2020-11-22 10:19

    use this

    NSString *myregex = @"<[^>]*>"; //regex to remove any html tag
    
    NSString *htmlString = @"bla bla";
    NSString *stringWithoutHTML = [hstmString stringByReplacingOccurrencesOfRegex:myregex withString:@""];
    

    don't forget to include this in your code : #import "RegexKitLite.h" here is the link to download this API : http://regexkit.sourceforge.net/#Downloads

提交回复
热议问题