RegexKitLite 使用详解
来源:互联网 发布:初中文化能学plc编程吗 编辑:程序博客网 时间:2024/05/16 06:16
1.匹配字符,并通过参数删选匹配字符
- (NSString *)RKL_METHOD_PREPEND(stringByMatching):(NSString*)regex capture:(NSInteger)capture;
NSString* searchString1 = @"http://www.e//isxample.com:80222080/http//isindex.ishtml";
NSString* regexString1 = @"(is)(ht)(ml)";
NSLog(@"portInteger: '%@'", [searchString1stringByMatching:regexString1capture:3L] );
/*
匹配字符 : ishtml
若参数capture:0L表示全部字符 --ishtml
若参数capture:1L表示正则表达式中第一个括号内匹配的字符(若不存在第一个括号,则argument is not valid程序崩溃)--is
若参数capture:2L表示正则表达式中第二个括号内匹配的字符(若不存在第二个括号,则argument is not valid程序崩溃)--ht
若参数capture:3L表示正则表达式中第三个括号内匹配的字符(若不存在第三个括号,则argument is not valid程序崩溃) -- ml
*/
NSString *searchString = @"<p>\r<img src=\"http://192.168.0.180/mobilemobile/UpFile/20140804134426.jpg\" /></p>\r<p>\r<span id=\"LabHome\">The information contained in this Manual cover all the services you need to participate successfully in the Exhibition. It provides you with all the necessary information on Exhibition Services and Order Forms to ensure a smooth <img src=\"http://192.168.0.180/mobilemobile/UpFile/14758.gif\" />and trouble-free run-up to MEDICAL MANUFACTURING ASIA 2014.</span></p>";
NSString *regexString = @"<img src=\"[^>]*\" />";
// 将匹配后的字符存放于数组当中
NSArray *matchArray = [searchString componentsMatchedByRegex:regexString];
NSLog(@"%@",matchArray);
// 将匹配后的字符替换成指定字符
NSString* matchString = [searchString stringByReplacingOccurrencesOfRegex:regexStringwithString:@"||================||"];
NSLog(@"%@",matchString);
NSString* searchString1 =@"http://www.e//isxample.com:80222080/http//isindex.ishtml";
NSString* regexString1 = @"(isi)(ndex)";
NSLog(@"%@",[searchString1 componentsMatchedByRegex:regexString1]);
NSLog(@"%@",[searchString1 captureComponentsMatchedByRegex:regexString1]);
参考博文:http://blog.csdn.NET/ios_long/article/details/6720650
- RegexKitLite 使用详解
- RegexKitLite 使用详解
- RegexKitLite的使用
- RegexKitLite的使用
- RegexKitLite
- ios 正则表达式RegexKitLite 使用
- ASIHTTPRequest 的使用 RegexKitLite的使用
- [IOS]开源库RegexKitLite正则表达式的使用
- 使用RegexKitLite.h编译错误及解决
- iOS中使用正则表达式 RegexKitLite
- ios-RegexKitLite框架的简单使用
- 使用RegexKitLite使iphone也可以使用正则表达式
- [iphone]使用(RegexKitLite)实现正则表达式 [转]
- iOS中使用RegexKitLite来试用正则表达式
- iOS中使用RegexKitLite来试用正则表达式
- [iphone]使用(RegexKitLite)实现正则表达式 [转]
- 【IOS 系列】iOS中使用RegexKitLite来试用正则表达式
- iOS中使用RegexKitLite来试用正则表达式
- openstack在centos7升级后无法重启或关机解决办法
- spring MVC +Hibernate+Struts2的工作流程图
- 各大型网站架构分析收集
- Android 启动性能优化 - kernel篇
- Redis系列(七):性能问题排查解决手册
- RegexKitLite 使用详解
- if(username.equals(“zxx”){}
- [C#从入门到放弃]OOP与集合
- 谈谈对js面向对象的理解
- Java Variable
- Razor基础
- 大型网站架构演变
- 海康摄像头+web调用(官方开发包)+手把手全方位扫盲
- Ubuntu or Deepin 上安装 mysql 数据库