NSRegularExpressionCaseInsensitive :忽略大小写
NSString *superString = @"aBcdeAbc";
NSString *subString = @"ab";
NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:subString options:NSRegularExpressionCaseInsensitive error:nil];
NSArray <NSTextCheckingResult *>*matches = [regex matchesInString:superString options:0 range:NSMakeRange(0, superString.length)];
[matches enumerateObjectsUsingBlock:^(NSTextCheckingResult * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
NSRange range = obj.range;
NSLog(@"range = %@, rangeString = %@",NSStringFromRange(range),[superString substringWithRange:range]);
}];
网友评论