using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"http(?:s)?:\/\/(?:www\.)?youtube\.com\/.*?watch%3Fv%([\d\w-_]+)";
string input = @"http://youtube.com/attribution_link?a=r_FgjB-RKNo&u=/watch%3Fv%3DB0_X8zWJd0Q%26feature%3Dem-uploademail
http://youtube.com/attribution_link?a=1crTn2Lx38I&u=/watch%3Fv%3DHhebhh2s5d4%26feature%3Dem-uploademail
http://youtube.com/attribution_link?a=_zMgiznzBto&u=/watch%3Fv%3D-kaoCPvUHJM%26feature%3Dem-uploademail
http://youtube.com/attribution_link?a=F8VReY1sT0A&u=/watch%3Fv%3D5RLM9rk0Q8s%26feature%3Dem-uploademail
https://www.youtube.com/watch?feature=player_detailpage&v=2eGUP16P_p4
";
foreach (Match m in Regex.Matches(input, pattern))
{
Console.WriteLine("'{0}' found at index {1}.", m.Value, m.Index);
}
}
}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for C#, please visit: https://msdn.microsoft.com/en-us/library/system.text.regularexpressions.regex(v=vs.110).aspx