IPhoneThird-party toolsRegexKitLiteReal-timeExpressionImplementation example is the content to be introduced in this article.ExpressionLet's look at the content.
1. GoRegexKitLiteDownload the class library and decompress it. There will be an example package and two files. The two files are actually used and added to the project.
2. Add libicucore. dylib frameworks to the project.
3. Now all nsstring objects can be called.RegexKitLite.
- NSString *email = @”kkk@aaa.com”;
- [email isMatchedByRegex:@"\\b([a-zA-Z0-9%_.+\\-]+)@([a-zA-Z0-9.\\-]+?\\.[a-zA-Z]{2,6})\\b”];
If YES is returned, the email format is used. Note that RegexKitLite uses a regular expression that is slightly different from wiki.
- searchString = @”http://www.example.com:8080/index.html”;
- regexString = @”\\bhttps?://[a-zA-Z0-9\\-.]+(?::(\\d+))?(?:(?:/[a-zA-Z0-9\\-._?,'+\\&%$=~*!():@\\\\]*)+)?”;
- NSInteger portInteger = [[searchString stringByMatching:regexString capture:1L] integerValue];
- NSLog(@”portInteger: ‘%ld’”, (long)portInteger);
- // 2008-10-15 08:52:52.500 host_port[8021:807] portInteger: ‘8080′
Take the http example in string.
Below are some common Regular ExpressionsExpressionActuallyRegexKitLiteOn the official website, I am afraid that my shoes will be lazy)Image click to zoom in
Note the escape characters ~~ Copying on safari will directly convert the website to a more user-friendly one)
The conversion tool and safari test support are also provided. The download may be slow, and you can wait patiently.
Summary:IPhoneThird-party toolsRegexKitLiteReal-timeExpressionThe implementation of the instance is complete. I hope this article will help you!