using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Text.RegularExpressions; namespace TEST { class Program { static void Main(string[] args) { string[] urls = { "http://www.google.com", "http://m...content-available-to-author-only...t.us", "www.amazon.com", "tinyurl.com", "itsaTrap!", "http://o...content-available-to-author-only...k.com/just/to/bee/sure", "http://t...content-available-to-author-only...k.com/Done", "http://brokenurl.s2", "This line isnt proper url", "try.to.fake.ur/rsa.r2", "myshort.link/page.html?param1=das", "link.com/?#", "this.is/dot/net/link/alike?param=1&something=2", "this.is/To/ControllerName/ActionTodDo?gimmeNumber=5", "this.is/To/ControllerName/ActionTodDo.fakePHP?gimmeNumber=5"}; Console.WriteLine("Start"); foreach(string s in urls) Console.WriteLine("["+s+"]"); Console.WriteLine("=================\n\n\n\n"); string[] urls2 = urls .Select(s => Regex.Match(s, @"(http://){0,1}[a-z0-9\-\.]{1,}\.[a-z]{2,5}", RegexOptions.IgnoreCase).ToString()) .Where(s => !string.IsNullOrEmpty(s)) .ToArray(); foreach (string s in urls2) Console.WriteLine("[" + s + "] "); Console.WriteLine("=================\n\n\n\n"); Console.ReadKey(); } } }