I\'m busy trying to create two regular expressions to filter the id from youtube and vimeo video\'s. I\'ve already got the following expressions;
YouTube: (y
In case you are writing some application with view model (e.g. ASP.NET MVC):
public string YouTubeUrl { get; set; }
public string YouTubeVideoId
{
get
{
var youtubeMatch =
new Regex(@"youtu(?:\.be|be\.com)/(?:.*v(?:/|=)|(?:.*/)?)([a-zA-Z0-9-_]+)")
.Match(this.YouTubeUrl);
return youtubeMatch.Success ? youtubeMatch.Groups[1].Value : string.Empty;
}
}