fork download
  1. using System;
  2. using System.Linq;
  3. using System.IO;
  4.  
  5. public class Test
  6. {
  7. public static void Main()
  8. {
  9. String[]uris = new[]{ "http://s...content-available-to-author-only...1.org/info.php","http://s...content-available-to-author-only...2.com/info/index.php","http://s...content-available-to-author-only...3.edu/", "http://s...content-available-to-author-only...3.edu/", "no uri", "" };
  10. var result = uris.Where(u => Uri.IsWellFormedUriString(u, UriKind.Absolute))
  11. .Select(u => {
  12. var p = new Uri(u).ToString();
  13. return p.Substring(0, p.LastIndexOf('/') +1);
  14. })
  15. .Distinct()
  16. .ToArray();
  17.  
  18. Console.Write(String.Join(Environment.NewLine,result));
  19. }
  20. }
Success #stdin #stdout 0.09s 37544KB
stdin
Standard input is empty
stdout
http://s...content-available-to-author-only...1.org/
http://s...content-available-to-author-only...2.com/info/
http://s...content-available-to-author-only...3.edu/