吃饱了就饿 发表于 2013-1-14 21:14:53

去掉NSString中的HTML标签

最近在用phonegap,经常出现字符串带有html标签。下面有个方法一步到位去掉HTML标签

+(NSString *)flattenHTML:(NSString *)html trimWhiteSpace:(BOOL)trim{    NSScanner *theScanner = ;    NSString *text = nil;      while ( == NO) {      // find start of tag       ;      // find end of tag       ;      // replace the found tag with a space      //(you can filter multi-spaces out later if you wish)      html =                                              withString:@""];    }      return trim ? ] : html;} 调用方法:

    notification33.alertBody =;
页: [1]
查看完整版本: 去掉NSString中的HTML标签