去掉Html标签方法

-(NSString *) getHtmlToText:(NSString*) inputString{
    NSString *result=[[NSString alloc] init];
    result=inputString;
    NSRegularExpression *reg=[[NSRegularExpression alloc] init];
    reg=[[NSRegularExpression alloc] initWithPattern:@"<([^>]+)>" options:NSRegularExpressionCaseInsensitive error:nil];
    result=[reg stringByReplacingMatchesInString:result options:0 range:NSMakeRange(0,[result length]) withTemplate:@""];
   
    result = [result stringByReplacingOccurrencesOfString:@"&nbsp;" withString:@""];
    result = [result stringByReplacingOccurrencesOfString:@" " withString:@""];
    result = [result stringByReplacingOccurrencesOfString:@"&ldquo;" withString:@""];
    result = [result stringByReplacingOccurrencesOfString:@"&rdquo;" withString:@""];
    return result;
}
posted @ 2013-01-23 11:29  天纯蓝  阅读(359)  评论(0编辑  收藏  举报