Advertisement
Asenval

Untitled

Feb 1st, 2013
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.78 KB | None | 0 0
  1. class ParsesURLAddress
  2. {
  3.     static void Main()
  4.     {
  5.         string str = "URL http://www.devbg.org/forum/index.php, URL http://www.fefevbg.org/forum/index.php";
  6.         //Console.WriteLine("Insert string");
  7.         //string str = Console.ReadLine();
  8.         string pattern = @"URL\s*(?<protocol>\w*?)\:[\\/]{2}(?<server>[^\\/]*)[\\/](?<resource>[^\s,;]*)";
  9.         MatchCollection matches = Regex.Matches(str, pattern);
  10.  
  11.         foreach (Match match in matches)
  12.         {
  13.             Console.WriteLine("[protocol] = \"{0}\"",match.Groups["protocol"].Value);
  14.             Console.WriteLine("[server] = \"{0}\"", match.Groups["server"].Value);
  15.             Console.WriteLine("[resource] = \"{0}\"", match.Groups["resource"].Value);
  16.             Console.WriteLine();
  17.         }
  18.     }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement