Youtube Video Id from URL - Swift3
问题 Basically I have a Youtube URL as string, I want to extract the video Id from that URL. I found some code in objective c that is as below: NSError *error = NULL; NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"?.*v=([^&]+)" options:NSRegularExpressionCaseInsensitive error:&error]; NSTextCheckingResult *match = [regex firstMatchInString:youtubeURL options:0 range:NSMakeRange(0, [youtubeURL length])]; if (match) { NSRange videoIDRange = [match rangeAtIndex:1];