using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"<a\s+href=""https?:\/\/?(?:www\.)?((?:(?!-)[A-Za-z0-9-]{1,63}(?<!-)\.)+[A-Za-z]{2,8})(?:""|\/).*?>(?:https?:\/\/)?(?:www\.)?\1";
string input = @"<span style=""color:rgb(128,0,0);font-weight:bold"">> Оформлен заказ в магазине <a href=""http://www.test1.com"" target=""_blank"">test1.com</a> </spant-family:arial,sans-serif>
<a href=""http://test.site.com/11222/sdf.html"">http://www.test.site.com</a><br style=""color:rgb(0,0,0);font-family:arial,sans-serif;font-size:12.8px""><span style=""color:rgb(0,0,0);font-family:arial,sans-serif;font-size:12.8px"">SOME MESSAGE TEXT</span><br style=""color:rgb(0,0,0);font-family:arial,sans-serif;font-size:12.8px""><a href=""http://www.test2.com/"">www.test2.com/123/test</a>
SOME TEXT</span><br style=""color:rgb(0,0,0);font-family:arial,sans-serif;font-size:12.8px""><a href=""http://www.TEsst.com/"">https://tesst.com</a><br style=""color:rgb(0,0,0);font-family:arial,sans-serif;font-size:12.8px""><span style=""color:rgb(0,0,0);font-family:arial,sans-serif;font-size:12.8px""> === =size:12.8px""><span style=""color:rgb(0,0,0);font-family:arial,sans-serif;font-size:12.8px""><a href=""http://site.org"">site.org</a>
";
RegexOptions options = RegexOptions.IgnoreCase | 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