Advertisement
Guest User

ParseURL.cs

a guest
Feb 1st, 2013
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.60 KB | None | 0 0
  1. using System;
  2.  
  3. class Program
  4. {
  5.     static void Main()
  6.     {
  7.         string URL = "http://www.codeproject.com/Articles/9099/The-30-Minute-Regex-Tutorial";
  8.  
  9.         string protocol = URL.Substring(0, URL.IndexOf(':', 0));
  10.  
  11.         int offset = URL.IndexOf(':', 0) + 3;
  12.         int nextSlash = URL.IndexOf('/', offset);
  13.  
  14.         string server = URL.Substring(offset, nextSlash-offset);
  15.         string resource = URL.Substring(nextSlash);
  16.  
  17.         Console.WriteLine("Protocol: " + protocol);
  18.         Console.WriteLine("Server: " + server);
  19.         Console.WriteLine("Resource: " + resource);
  20.     }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement