#pragma mark - 获取url特定的参数 -(NSString *) jiexi:(NSString *)CS webaddress:(NSString *)webaddress { NSError *error; NSString *regTags=[[NSString alloc] initWithFormat:@"(^|&|\\?)+%@=+([^&]*)(&|$)",CS]; NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:regTags options:NSRegularExpressionCaseInsensitive error:&error]; // 执行匹配的过程 NSArray *matches = [regex matchesInString:webaddress options:0 range:NSMakeRange(0, [webaddress length])]; for (NSTextCheckingResult *match in matches) { NSString *tagValue = [webaddress substringWithRange:[match rangeAtIndex:2]]; // 分组2所对应的串 return tagValue; } return @""; }
时间: 2024-10-22 10:51:30