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

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);
    }

你可能感兴趣的:(iOS 正则表达式组匹配 数字、字符)