
1 张图片
作者
描述
这个项目是一系列对 NSRegularExpression 和 NSString 进行分类的 Objective-C,使得使用更加简单和紧凑。
//Using NSRegularExpression
NSString* string = @"I have 2 dogs.";
NSRegularExpression *regex = [NSRegularExpression
regularExpressionWithPattern:@"\\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+")];
.
了解更多信息: https://github.com/bendytree/Objective-C-RegEx-Categories