I have a URL of a YouTube video. Now, I need to extract a string and save it to a variable. Here, I need to extract videoid from the URL. The link is:
https://www.youtube.com/watch?v=iTcq6L-PaDQ
Now, I need to extract iTcq6L-PaDQ
in Swift 3.
Swift 3.0
You can get Video ID as substring from String Url like below.
let url = URL(string: "https://www.youtube.com/watch?v=iTcq6L-PaDQ" )!.absoluteString
let Id = url.substring(from: url.range(of: "?v=")!.upperBound)