using System; using System.Text.RegularExpressions; public class Test { public static void Main() { var text = "Look at http://google.com some more text here possibly,\nLook at www.google.com some more text here possibly"; text = text.Trim(); text = Regex.Replace(text, @"((https?|ftp)://(?:www\.|(?!www))[^\s.]+\.\S{2,}|www\.\S+\.\S{2,})", m => m.Groups[2].Success ? string.Format("{0}", m.Groups[1].Value) : string.Format("{0}", m.Groups[1].Value)); Console.WriteLine(text); } }