Real expression Implementation of the third-party RegexKitLite tool in iPhone

Source: Internet
Author: User

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.

 
 
  1. NSString *email = @”kkk@aaa.com”;  
  2. [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.

 
 
  1. searchString = @”http://www.example.com:8080/index.html”;  
  2. regexString  = @”\\bhttps?://[a-zA-Z0-9\\-.]+(?::(\\d+))?(?:(?:/[a-zA-Z0-9\\-._?,'+\\&%$=~*!():@\\\\]*)+)?”;  
  3. NSInteger portInteger = [[searchString stringByMatching:regexString capture:1L] integerValue];  
  4. NSLog(@”portInteger: ‘%ld’”, (long)portInteger);  
  5. // 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!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.