Advertisement
dkeray

Untitled

Jan 28th, 2013
333
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.78 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. class ExtractsURL
  8. {
  9.     public static void ExtractURL(string url)
  10.     {
  11.         int index = 0;
  12.         index = url.IndexOf(':');
  13.         Console.WriteLine("[protocol] = \"{0}\"", url.Substring(0, index));
  14.         url = url.Replace(url.Substring(0, index + 3), "");
  15.  
  16.         index = url.IndexOf('/');
  17.         Console.WriteLine("[server] = \"{0}\"", url.Substring(0, index));
  18.         url = url.Replace(url.Substring(0, index), "");
  19.  
  20.         Console.WriteLine("[resource] = \"{0}\"", url);
  21.  
  22.     }
  23.  
  24.     static void Main()
  25.     {
  26.         string url = "http://dkeray.wordpress.com/2012/12/30/c-exam-2012-problem-4-uk-flag/";
  27.         ExtractURL(url);
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement