处理类似于<a href="http://weibo.com/"rel="nofollow">微博 weibo.com</a>的字符串的方法------提取出微博weibo.com的方法

//第一种方法--暴力截取(或者将字符串截取为NSArray--<a href="http://weibo.com/"rel="nofollow">微博 weibo.com</a>

// NSRange range = [self.sourcerangeOfString:@">"];

// self.source = [self.sourcesubstringFromIndex:range.location + 1];//微博 weibo.com</a>

//// NSLog(@"%@",self.source);//微博weibo.com</a>

// NSRange range1 = [self.sourcerangeOfString:@"<"];

// self.source = [self.sourcesubstringToIndex:range1.location];//微博 weibo.com

// //方法二----正则表达式(不导入第三方文件)

// NSString *regex =@">[.\\w\\s]+<";//------构建正则表达式:"."表示换行符意外的任意字符;"\\w"表示\加单词;"\\s"表示\加空白符;"+"表示重复一次或者多次

// NSRegularExpression *regular =[[NSRegularExpression alloc] initWithPattern:regexoptions:NSRegularExpressionCaseInsensitiveerror:nil];

// NSArray *array = [regularmatchesInString:self.source options:NSMatchingReportProgress range:NSMakeRange(0,self.source.length)];//仅有一个元素--->//>微博weibo.com<

// if (array.count > 0) {

// NSTextCheckingResult *result =array[0];

////NSLog(@"%ld",array.count);

// NSRange range = result.range;

// range.location += 1;

// range.length -= 2;

// self.source = [self.sourcesubstringWithRange:range];

////NSLog(@"%@",self.source);

// }

//第三种方法----导入第三方框架(RegexKitLite框架)--将RegexKitLite包含的文件由MRC改为适应与ARC(-fno-objc-arc)----并导入系统框架libicucore文件---并将#import"RegexKitLite.h"文件导入此文件中

NSString *regex = @">[.\\w\\s]+<";//------构建正则表达式:"."表示换行符意外的任意字符;"\\w"表示\加单词;"\\s"表示\加空白符;"+"表示重复一次或者多次

NSArray *array = [self.sourcecomponentsMatchedByRegex:regex];//仅有一个元素--->//>微博weibo.com<

if (array.count > 0) {

NSRange range = {1,[array[0] length] - 2};

self.source = [array[0] substringWithRange:range];

}