using System.Text.RegularExpressions;
public static void Main()
Console.WriteLine("-----");
string html = "<p class=\"MsoNormal\"><a href=\"http://www.google.com\" moz-do-not-send=\"true\">www.yahoo.com</a><o:p></o:p></p>";
string pattern = @"(?<!href="")\b(?:https?://|ftp://)\S+\b";
string result = Regex.Replace(html, pattern, match =>
string url = match.Value;
int index = url.IndexOf('<');
url = url.Substring(0, index);
Console.WriteLine("-----");
return "<a href=\"" + url + "\">" + url + "</a>";
Console.WriteLine(result);