svetlozar_kirkov

Split URL (Exercise)

Oct 10th, 2014
266
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.65 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using System.Text.RegularExpressions;
  5.  
  6. namespace ConsoleTests
  7. {
  8.     class ConsoleTests
  9.     {
  10.         static void Main()
  11.         {
  12.             string input = Console.ReadLine();
  13.             string[] template = new string[3] {"[protocol]", "[server]", "[resource]"};
  14.             char[] separators = new char[2] {':', '/',};
  15.             string[] split = input.Split(separators,StringSplitOptions.RemoveEmptyEntries);
  16.             for (int i = 0; i < split.Length; i++)
  17.             {
  18.                 Console.WriteLine("{0}={1}",template[i],split[i]);
  19.             }
  20.  
  21.         }
  22.     }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment