小墨的iOS移动端APP代码

朱海文 3e28daaec5 init 3 years ago
..
LICENSE.txt 3e28daaec5 init 3 years ago
RegExCategories.h 3e28daaec5 init 3 years ago
RegExCategories.m 3e28daaec5 init 3 years ago
readme.md 3e28daaec5 init 3 years ago

readme.md

Objective-C RegEx Categories

Overview

This project is a collection of objective-c categories for NSRegularExpression and NSString that make usage easier and more concise. For example:

//Using NSRegularExpression
NSString* string = @"I have 2 dogs.";
NSRegularExpression *regex = [NSRegularExpression regular ExpressionWithPattern:@"\\d+" options:NSRegularExpressionCaseInsensitive error:&error];
NSTextCheckingResult *match = [regex firstMatchInString:string options:0 range:NSMakeRange(0, [string length])];
BOOL isMatch = match != nil;

// Using this library
BOOL isMatch = [@"I have 2 dogs." isMatch:RX(@"\\d+")];

Getting Started

This library has no dependencies and works for iOS4+ and OSX v10.7+.

To install it, just copy these two files into your project:

  • RegExCategories.h
  • RegExCategories.m

You may want to add it to your Prefix.pch so that is is available across your code base.

#ifdef __OBJC__
    /* ...other references... */
    #import "RegExCategories.h"
#endif

You also need to have ARC enabled on your XCode project. If you don't then add the -fobjc-arc flag on Objective-C-Regex-Categories.m under Targets > Build Phases > Compile Sources (more info here).

Examples

Support

If you need help, submit an issue, send a pull request, or tweet at me @BendyTree.

Licensing

MIT License - do whatever you want, just (1) provide attribution and (2) don't hold me liable.

Travis-CI

This repository includes unit tests written in the XCTest framework. These test are automatically verified using Travis-CI. Here is the current status:

Build Status