iOS 正则表达式组匹配 数字、字符

2018-07-16  本文已影响15人  键盘仔
NSError *error;
    NSRegularExpression *attachmentExpression = [NSRegularExpression regularExpressionWithPattern:@"(\\d*)" options:NSRegularExpressionCaseInsensitive error:&error];
    NSArray *matches = [attachmentExpression matchesInString:result
                                               options:0
                                                 range:NSMakeRange(0, [result length])];
    for (NSTextCheckingResult *match in matches) {
        //NSRange matchRange = [match range];
        NSRange matchRange = [match rangeAtIndex:1];
        NSString *matchString = [result substringWithRange:matchRange];
        NSLog(@"%@", matchString);
    }

上一篇下一篇

猜你喜欢

热点阅读