fork download
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Text.RegularExpressions;
  6.  
  7. namespace TEST
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. string[] urls = {
  14. "http://www.google.com",
  15. "http://m...content-available-to-author-only...t.us",
  16. "www.amazon.com",
  17. "tinyurl.com",
  18. "itsaTrap!",
  19. "http://o...content-available-to-author-only...k.com/just/to/bee/sure",
  20. "http://t...content-available-to-author-only...k.com/Done",
  21. "http://brokenurl.s2",
  22. "This line isnt proper url",
  23. "try.to.fake.ur/rsa.r2",
  24. "myshort.link/page.html?param1=das",
  25. "link.com/?#",
  26. "this.is/dot/net/link/alike?param=1&something=2",
  27. "this.is/To/ControllerName/ActionTodDo?gimmeNumber=5",
  28. "this.is/To/ControllerName/ActionTodDo.fakePHP?gimmeNumber=5"};
  29. Console.WriteLine("Start");
  30. foreach(string s in urls)
  31. Console.WriteLine("["+s+"]");
  32. Console.WriteLine("=================\n\n\n\n");
  33. string[] urls2 = urls
  34. .Select(s => Regex.Match(s, @"(http://){0,1}[a-z0-9\-\.]{1,}\.[a-z]{2,5}", RegexOptions.IgnoreCase).ToString())
  35. .Where(s => !string.IsNullOrEmpty(s))
  36. .ToArray();
  37. foreach (string s in urls2)
  38. Console.WriteLine("[" + s + "] ");
  39. Console.WriteLine("=================\n\n\n\n");
  40. Console.ReadKey();
  41. }
  42. }
  43. }
  44.  
Success #stdin #stdout 0.07s 37320KB
stdin
Standard input is empty
stdout
Start
[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]
=================




[http://www.google.com] 
[http://m...content-available-to-author-only...t.us] 
[www.amazon.com] 
[tinyurl.com] 
[http://o...content-available-to-author-only...k.com] 
[http://t...content-available-to-author-only...k.com] 
[try.to.fake.ur] 
[myshort.link] 
[link.com] 
[this.is] 
[this.is] 
[this.is] 
=================