Today i had to write a quick method to extract the YouTube video id from a YouTube video URL. So on with the show, lets get onto the code.
private string GetYouTubeID(string youTubeUrl) { //Setup the RegEx Match and give it Match regexMatch = Regex.Match(youTubeUrl, "^[^v]+v=(.{11}).*",
RegexOptions.IgnoreCase); if (regexMatch.Success) { return "http://www.youtube.com/v/" + regexMatch.Groups[1].Value +
"&hl=en&fs=1"; } return youTubeUrl; }