object - c 在URL中截取特定参数的值
#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 @""; }