Regex CategoriesObjective-C 类别采集

联合创作 · 2023-09-27 19:49

Regex Categories 是一款为 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+")];

浏览 4
点赞
评论
收藏
分享

手机扫一扫分享

编辑
举报
评论
图片
表情
推荐
点赞
评论
收藏
分享

手机扫一扫分享

编辑
举报