using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"(content|href)=\""(?<url>(http|https)://www\.youtube\.com[^\""]+watch[^\""]+)\""";
string input = @"<html lang=""es""><head>
<meta http-equiv=""Content-Type"" content=""text/html; charset=utf-8""><meta content=""text/html; charset=utf-8""><style type=""text/css"">
<!--
*
{font-family:arial,Arial,sans-serif}
@media only screen and (max-device-width: 480px) {
body.suppress-border-on-mobile
{margin:0!important;
border:0!important;
padding:0!important}
table.suppress-on-mobile, td.suppress-on-mobile, div.suppress-on-mobile, img.suppress-on-mobile, span.suppress-on-mobile
{display:none!important;
width:0px!important;
height:0px!important;
line-height:0px!important;
margin:0!important;
border:0!important;
padding:0!important}
table.outer-container-width, td.outer-container-width
{width:640px!important}
td.outer-container-padding-width
{width:20px!important}
table.inner-container-width, td.inner-container-width
{width:600px!important}
table.header-container-width
{width:600px!important;
height:100px!important}
td.header_left_padding_width
{width:25px!important}
td.logo_container_size
{width:575px!important;
height:100px!important}
img.header_logo_size
{height:47px!important}
table.footer-padding-width, td.footer-padding-width
{width:30px!important}
table.footer-width, td.footer-width
{width:540px!important}
td.footer-font, div.footer-font
{font-size:20px!important;
line-height:30px!important}
table.footer-content-padding-height, td.footer-content-padding-height
{height:30px!important}
table.large-section-padding-height, td.large-section-padding-height
{height:16px!important}
table.small-section-padding-height, td.small-section-padding-height
{height:20px!important}
table.content-container-padding-width, td.content-container-padding-width
{width:30px!important}
table.content-container-padding-height, td.content-container-padding-height
{height:30px!important}
table.content-container-width, td.content-container-width
{width:540px!important}
span.video-title-font-class, td.video-title-font-class, div.greeting-font, td.greeting-font
{font-size:24px!important;
line-height:30px!important}
a.video-link-font-class, div.video-link-font-class, td.video-link-font-class
{font-size:20px!important;
line-height:30px!important}
span.meta-data-font, div.meta-data-font, a.meta-data-font, td.meta-data-font
{display:block!important;
font-size:20px!important;
line-height:36px!important}
td.small-meta-data-font
{font-size:25px!important;
line-height:30px!important}
table.video-content-padding-height, td.video-content-padding-height
{height:45px!important}
td.avatar-size, img.avatar-size
{width:54px!important;
height:54px!important}
img.large-avatar-size
{height:32px!important}
img.channel-avatar-size
{width:80px!important;
height:80px!important}
img.thumbnail-size-class, td.thumbnail-size-class
{width:100px!important;
height:56px!important}
table.more-videos-size
{height:100px!important}
div.more-videos-font, td.more-videos-font
{font-size:24px!important;
line-height:27px!important}
table.more-videos-button-size
{width:230px!important;
height:60px!important}
td.more-videos-button-width
{width:250px!important}
td.more-videos-text-width
{width:270px!important}
table.video-spotlight-width
{width:600px!important;
height:332px!important}
td.video-spotlight-size, img.video-spotlight-size
{width:600px!important;
height:332px!important}
table.regular-button-height
{height:60px!important}
td.regular-button-padding-width
{width:20px!important}
td.regular-button-font
{font-size:27.5px!important;
line-height:27.5px!important}
img.play-button-img-size
{width:20px!important;
height:20px!important}
table.large-button-size
{width:600px!important;
height:70px!important}
table.video-2col-size
{width:600px!important}
table.video-2col-width, td.video-2col-width
{width:600px!important}
img.video-2col-thumb-size
{width:600px!important;
height:332px!important}
table.video-2col-outer-container-size, td.video-2col-outer-container-size
{width:600px!important}
table.video-2col-inner-container-size, td.video-2col-inner-container-size
{width:540px!important}
table.video-2col-inner-container-width, td.video-2col-inner-container-width
{width:540px!important}
div.section-title-font, td.section-title-font
{font-size:30px!important;
line-height:35px!important}
div.section-subtitle-font, td.section-subtitle-font
{font-size:25px!important;
line-height:25px!important}
table.video-3col-padding-height, td.video-3col-padding-height
{height:55px!important}
img.video-3col-thumb-size, table.video-3col-thumb-size
{width:600px!important;
height:332px!important}
table.video-3col-width, td.video-3col-width
{width:600px!important}
table.inner-3col-content-container-width, td.inner-3col-content-container-width
{width:600px!important}
td.small-pad-width
{width:20px!important}
img.channel-avatar-size
{width:80px!important;
height:80px!important}
span.follow-and-subs-font
{display:block!important;
font-size:24px!important;
line-height:27px!important;
max-height:30px!important}
td.social-logo-padding-width
{width:32px!important}
table.channel-owner-block-content-width, td.channel-owner-block-content-width
{width:420px!important}
td.show-only-on-mobile
{display:block!important;
width:100%!important;
max-height:100%!important;
overflow:visible!important}
td.show-not-on-mobile, tr.show-not-on-mobile
{display:none!important;
visibility:hidden!important}
}
-->
</style><style type=""text/css"">
<!--
*
{font-family:arial,Arial,sans-serif}
@media only screen and (max-device-width: 480px) {
body[class=suppress-border-on-mobile]
{margin:0!important;
border:0!important;
padding:0!important}
table[class=suppress-on-mobile], td[class=suppress-on-mobile], div[class=suppress-on-mobile], img[class=suppress-on-mobile], span[class=suppress-on-mobile]
{display:none!important;
width:0px!important;
height:0px!important;
line-height:0px!important;
margin:0!important;
border:0!important;
padding:0!important}
table[class=outer-container-width], td[class=outer-container-width]
{width:640px!important}
td[class=outer-container-padding-width]
{width:20px!important}
table[class=inner-container-width], td[class=inner-container-width]
{width:600px!important}
table[class=header-container-width]
{width:600px!important;
height:100px!important}
td[class=header_left_padding_width]
{width:25px!important}
td[class=logo_container_size]
{width:575px!important;
height:100px!important}
img[class=header_logo_size]
{height:47px!important}
table[class=footer-padding-width], td[class=footer-padding-width]
{width:30px!important}
table[class=footer-width], td[class=footer-width]
{width:540px!important}
td[class=footer-font], div[class=footer-font]
{font-size:20px!important;
line-height:30px!important}
table[class=footer-content-padding-height], td[class=footer-content-padding-height]
{height:30px!important}
table[class=large-section-padding-height], td[class=large-section-padding-height]
{height:16px!important}
table[class=small-section-padding-height], td[class=small-section-padding-height]
{height:20px!important}
table[class=content-container-padding-width], td[class=content-container-padding-width]
{width:30px!important}
table[class=content-container-padding-height], td[class=content-container-padding-height]
{height:30px!important}
table[class=content-container-width], td[class=content-container-width]
{width:540px!important}
span[class=video-title-font-class], td[class=video-title-font-class], div[class=greeting-font], td[class=greeting-font]
{font-size:24px!important;
line-height:30px!important}
a[class=video-link-font-class], div[class=video-link-font-class], td[class=video-link-font-class]
{font-size:20px!important;
line-height:30px!important}
span[class=meta-data-font], div[class=meta-data-font], a[class=meta-data-font], td[class=meta-data-font]
{display:block!important;
font-size:20px!important;
line-height:36px!important}
td[class=small-meta-data-font]
{font-size:25px!important;
line-height:30px!important}
table[class=video-content-padding-height], td[class=video-content-padding-height]
{height:45px!important}
td[class=avatar-size], img[class=avatar-size]
{width:54px!important;
height:54px!important}
img[class=large-avatar-size]
{width:32px!important}
img[class=channel-avatar-size]
{width:80px!important;
height:80px!important}
table[class=more-videos-size]
{height:100px!important}
div[class=more-videos-font], td[class=more-videos-font]
{font-size:24px!important;
line-height:27px!important}
table[class=more-videos-button-size]
{width:230px!important;
height:60px!important}
td[class=more-videos-button-width]
{width:250px!important}
td[class=more-videos-text-width]
{width:270px!important}
table[class=video-spotlight-width]
{width:600px!important;
height:332px!important}
td[class=video-spotlight-size], img[class=video-spotlight-size]
{width:600px!important;
height:332px!important}
table[class=regular-button-height]
{height:60px!important}
td[class=regular-button-padding-width]
{width:20px!important}
td[class=regular-button-font]
{font-size:27.5px!important;
line-height:27.5px!important}
img[class=play-button-img-size]
{width:20px!important;
height:20px!important}
table[class=large-button-size]
{width:600px!important;
height:70px!important}
table[class=video-2col-size]
{width:600px!important}
table[class=video-2col-width], td[class=video-2col-width]
{width:600px!important}
img[class=video-2col-thumb-size]
{width:600px!important;
height:332px!important}
table[class=video-2col-outer-container-size], td[class=video-2col-outer-container-size]
{width:600px!important}
table[class=video-2col-inner-container-size], td[class=video-2col-inner-container-size]
{width:540px!important}
table[class=video-2col-inner-container-width], td[class=video-2col-inner-container-width]
{width:540px!important}
div[class=section-title-font], td[class=section-title-font]
{font-size:30px!important;
line-height:35px!important}
div[class=section-subtitle-font], td[class=section-subtitle-font]
{font-size:25px!important;
line-height:25px!important}
table[class=video-3col-padding-height], td[class=video-3col-padding-height]
{height:55px!important}
img[class=video-3col-thumb-size], table[class=video-3col-thumb-size]
{width:600px!important;
height:332px!important}
table[class=video-3col-width], td[class=video-3col-width]
{width:600px!important}
table[class=inner-3col-content-container-width], td[class=inner-3col-content-container-width]
{width:600px!important}
td[class=small-pad-width]
{width:20px!important}
img[class=channel-avatar-size]
{width:80px!important;
height:80px!important}
img[class=thumbnail-size-class], td[class=thumbnail-size-class]
{width:80px!important;
height:44px!important}
span[class=follow-and-subs-font]
{display:block!important;
font-size:24px!important;
line-height:27px!important;
max-height:30px!important}
td[class=social-logo-padding-width]
{width:32px!important}
table[class=channel-owner-block-content-width], td[class=channel-owner-block-content-width]
{width:420px!important}
td[class=show-only-on-mobile]
{display:block!important;
width:100%!important;
max-height:100%!important;
overflow:visible!important}
td[class=show-not-on-mobile], tr[class=show-not-on-mobile]
{display:none!important;
visibility:hidden!important}
table, td
{width:500px!important}
}
-->
</style></head><body class=""suppress-border-on-mobile""><span style=""display:none!important; visibility:hidden; width:0; height:0; opacity:0; color:transparent"">En directo en YouTube: AstridSofficialVEVO - Astrid S - Dance Dance Dance (Official Music Video).</span> <table class=""outer-container-width"" width=""680"" bgcolor=""transparent"" align=""center"" valign=""top"" cellspacing=""0"" cellpadding=""0"" border=""0""><tbody><tr><td class=""outer-container-padding-width"" width=""40""></td><td class=""inner-container-width"" width=""600""><table class=""inner-container-width"" width=""600"" align=""center"" cellspacing=""0"" cellpadding=""0"" border=""0""><tbody><tr><td><table class=""header-container-width"" width=""600"" align=""left"" valign=""center"" cellspacing=""0"" cellpadding=""0"" border=""0""><tbody><tr><td class=""logo_container_size"" width=""584"" valign=""center""><a href=""https://www.youtube.com/attribution_link?a=IGCom2KEH-lFJgHW&u=/""><img alt=""Youtube Logo"" class=""header_logo_size"" height=""30"" src=""http://www.gstatic.com/youtube/img/branding/youtubelogo/1x/youtubelogo_60.png"" border=""0"" style=""display:block""></a> </td></tr></tbody></table></td></tr><tr><td style=""max-height:0px; font-size:0; display:none""><hr class=""inner-container-width"" width=""600"" style=""height:0px; border:none; border-color:transparent; padding:0px; margin:0px""></td></tr><tr><td class=""large-section-padding-height"" height=""20""></td></tr><tr><td><table class=""inner-container-width"" width=""600"" align=""center"" valign=""center"" cellspacing=""0"" cellpadding=""0"" border=""0""><tbody><tr><td><table class=""video-spotlight-width"" width=""600"" align=""center"" cellspacing=""0"" cellpadding=""0"" border=""0""><tbody><tr style=""><td colspan=""3""><a href=""https://www.youtube.com/attribution_link?a=IGCom2KEH-lFJgHW&u=/watch%3Fv%3DW0ToDn9jXW8%26feature%3Dem-lsp"" class=""nonplayable"" style=""text-decoration:none; display:block""><table aria-label=""Astrid S - Dance Dance Dance (Official Music Video)"" class=""video-spotlight-width"" width=""600"" align=""center"" background=""http://i.ytimg.com/vi/W0ToDn9jXW8/sddefault.jpg?sqp=-oaymwEGCIAFEOgC&rs=AMzJL3m-iY1ZW8EiY3QwRalAMfq3atBT-Q&feature=em-lsp"" height=""338"" cellspacing=""0"" cellpadding=""0"" border=""0"" style=""background-repeat:no-repeat; background-size:cover; background-position:center""><tbody><tr style=""><td aria-label=""Astrid S - Dance Dance Dance (Official Music Video)""><img src=""https://www.gstatic.com/youtube/img/email/transparent_pixel.png"" alt=""Astrid S - Dance Dance Dance (Official Music Video)"" width=""600"" style=""max-height:300px""> </td></tr><tr aria-label=""Astrid S - Dance Dance Dance (Official Music Video)"" scope=""row"" style=""><td aria-label=""Astrid S - Dance Dance Dance (Official Music Video)"" class=""footer-font"" valign=""bottom"" width=""600"" style=""color:#fff; text-align:right; font-size:12px""><div style=""margin-bottom:8px; margin-right:8px; border-radius:2px; background-color:#E62117; padding:2px 4px; display:inline-block"">PREMIERE</div></td></tr></tbody></table></a></td></tr><tr><td><table class=""large-section-padding-height"" height=""16"" cellspacing=""0"" cellpadding=""0"" border=""0""><tbody><tr><td class=""large-section-padding-height"" height=""16""></td></tr></tbody></table></td></tr><tr><td><table class=""content-container-width"" width=""560"" cellspacing=""0"" cellpadding=""0"" border=""0"" style=""table-layout:fixed""><tbody><tr><td class=""avatar-size"" width=""32"" style=""vertical-align:top""><a href=""><img class=""avatar-size"" src=""https://lh6.googleusercontent.com/-YdGE1ZRP_7k/AAAAAAAAAAI/AAAAAAAAAAA/lTcGNRWN4cc/s88-c-mo/photo.jpg"" width=""32"" border=""0"" style=""display:block; border-radius:50%""> </a></td><td class=""small-pad-width"" width=""16""></td><td><table class=""content-container-width"" width=""540"" cellspacing=""0"" cellpadding=""0"" border=""0"" style=""table-layout:fixed""><tbody><tr><td valign=""center""><table class=""content-container-width"" cellspacing=""0"" cellpadding=""0"" border=""0"" style=""table-layout:fixed""><tbody><tr><td style=""padding-bottom:4px""><a href=""https://www.youtube.com/attribution_link?a=IGCom2KEH-lFJgHW&u=/watch%3Fv%3DW0ToDn9jXW8%26feature%3Dem-lsp"" style=""text-decoration:none""><span class=""video-title-font-class"" valign=""center"" style=""font-family:Roboto,sans-serif; font-size:14px; color:#212121; line-height:20px"">Astrid S - Dance Dance Dance (Official Music Video) </span></a></td></tr><tr><td><a class=""video-link-font-class"" href=""https://www.youtube.com/attribution_link?a=IGCom2KEH-lFJgHW&u=/user/AstridSofficialVEVO%3Ffeature%3Dhttp://www.youtube.com/user/AstridSofficialVEVO%253Ffeature%253Dem-lsp"" style=""font-family:Roboto,sans-serif; font-size:12px; color:#757575; line-height:16px; letter-spacing:0px; text-decoration:none"">AstridSofficialVEVO </a></td></tr></tbody></table></td></tr></tbody></table></td></tr></tbody></table></td></tr><tr><td><table class=""large-section-padding-height"" height=""16"" cellspacing=""0"" cellpadding=""0"" border=""0""><tbody><tr><td class=""large-section-padding-height"" height=""16""></td></tr></tbody></table></td></tr></tbody></table></td></tr></tbody></table></td></tr><hr style=""display:block; height:1px; border:0; border-top:1px solid #eaeaea; margin-bottom:16px; padding:0""><tr><td><table class=""inner-container-width"" cellspacing=""0"" cellpadding=""0"" border=""0""><tbody><tr><td class=""footer-font"" style=""color:#757575; font-size:12px; line-height:16px; font-family:Roboto,sans-serif; letter-spacing:0px; word-wrap:break-word"">Te hemos enviado este correo electrónico porque querías recibir las novedades de <a href=""https://www.youtube.com/attribution_link?a=IGCom2KEH-lFJgHW&u=/user/AstridSofficialVEVO%3Ffeature%3Dhttp://www.youtube.com/user/AstridSofficialVEVO%253Ffeature%253Dem-lsp"" style=""text-decoration:none; color:#065FD4"">AstridSofficialVEVO</a>. Si quieres dejar de recibirlas, puedes <a href=""https://www.youtube.com/attribution_link?noapp=1&a=IGCom2KEH-lFJgHW&u=/channel_updates_unsubscribe%3Fuid%3DXjBfPpnEmlhjuQFdvbsPkQ%26channel_id%3DUCkZc1mlptb_EI3n9kYUGgEA%26token%3DJ_uooufy6Em7wS-ZRVEt5RlBOsF8MTU5MTQ1OTIxOEAxNTkxNDU5MjE4%26feature%3Dem-lsp"" style=""text-decoration:none; color:#065FD4"">cancelar tu suscripción aquí</a>. </td></tr><tr><td><table class=""footer-content-padding-height"" height=""16"" cellspacing=""0"" cellpadding=""0"" border=""0""><tbody><tr><td class=""footer-content-padding-height"" height=""16""></td></tr></tbody></table></td></tr><tr><td class=""footer-font"" style=""color:#757575; font-size:12px; line-height:16px; font-family:Roboto,sans-serif; letter-spacing:0px; text-decoration:none"">© 2020 YouTube, LLC 901 Cherry Ave, San Bruno, CA 94066 </td></tr><tr><td><table class=""footer-content-padding-height"" height=""16"" cellspacing=""0"" cellpadding=""0"" border=""0""><tbody><tr><td class=""footer-content-padding-height"" height=""16""></td></tr></tbody></table></td></tr></tbody></table></td></tr></tbody></table></td><td class=""outer-container-padding-width"" width=""40""></td></tr><tr><td colspan=""3""><table class=""content-container-width"" width=""600"" height=""18"" align=""left"" height=""332"" cellspacing=""0"" cellpadding=""0"" border=""0"" style=""background-repeat:no-repeat; background-size:100% 100%""><tbody><tr><td class=""outer-container-padding-width"" width=""40""></td><td width=""20"" aria-label=""YouTube Link""><a href=""https://www.youtube.com/attribution_link?a=IGCom2KEH-lFJgHW&u=/youtube"" target=""_blank""><img alt=""YouTube"" class=""large-avatar-size"" src=""https://www.gstatic.com/youtube/img/email/youtube_email_icon_grey.png"" height=""18"" border=""0""> </a></td><td class=""social-logo-padding-width"" width=""16""></td><td aria-label=""Twitter Link""><a href=""https://twitter.com/YouTube"" target=""_blank""><img alt=""Twitter"" class=""large-avatar-size"" src=""https://www.gstatic.com/youtube/img/email/twitter_email_icon_grey.png"" height=""18"" border=""0""> </a></td></tr></tbody></table></td></tr></tbody></table><img class=""open_tracking_img"" src=""https://www.youtube.com/attribution_link?a=IGCom2KEH-lFJgHW&u=/gen_204%3Fa%3D"" width=""1"" height=""1"" style=""display:none!important; visibility:hidden; width:0; height:0; opacity:0; color:transparent""> </body></html>";
RegexOptions options = RegexOptions.Multiline;
foreach (Match m in Regex.Matches(input, pattern, options))
{
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