中正则

网站:

http://codecloud.net/regular-3519.html

截取文字

NSString *searchText = @"要在标题栏上显示的文字test11111111111111111111<img src=\http://www.myexception.cn/img/2013/02/01/1138391367.png\"></body</html>";

//    NSError *error = NULL;//    NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"(?<=title\>).*(?=</title)"options:NSRegularExpressionCaseInsensitive error:&error];

NSTextCheckingResult *result = [regex firstMatchInString:searchText options:0 range:NSMakeRange(0, [searchText length])];

if (result) {

   NSLog(@"%@\n", [searchText substringWithRange:result.range]);

}

下面的是图片的正则表达式(好像是很好用,有简单版的,但是站主推荐这个)

((http[s]{0,1}|ftp)://[a-zA-Z0-9\\.\\-]+\\.([a-zA-Z]{2,4})(:\\d+)?(/[a-zA-Z0-9\\.\\-~!@#$%^&*+?:_/=<>]*)?)|(www.[a-zA-Z0-9\\.\\-]+\\.([a-zA-Z]{2,4})(:\\d+)?(/[a-zA-Z0-9\\.\\-~!@#$%^&*+?:_/=<>]*)?)

网站:

http://blog.csdn.net/ztp800201/article/details/8116081

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容