Advertisement
Guest User

UrlParser

a guest
Jun 8th, 2016
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. namespace _05.UrlParser
  2. {
  3. using System;
  4. using System.Text.RegularExpressions;
  5.  
  6. public class UrlMain
  7. {
  8. public static void Main(string[] args)
  9. {
  10. Regex regex = new Regex("((.*?):\\/\\/)?(.*?)(\\/([\\w\\W]+)|$)");
  11. Match match = regex.Match(Console.ReadLine());
  12.  
  13. Console.WriteLine($"[protocol] = \"{match.Groups[2]}\"");
  14. Console.WriteLine($"[server] = \"{match.Groups[3]}\"");
  15. Console.WriteLine($"[resource] = \"{match.Groups[5]}\"");
  16. }
  17. }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement