Advertisement
Guest User

Untitled

a guest
May 29th, 2015
509
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.79 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text.RegularExpressions;
  5.  
  6. class ExtractHyperlinks
  7. {
  8.     static void Main()
  9.     {
  10.         string input = Console.ReadLine();
  11.         string pattern = @"<a.*?(?<!"">)href\s*?=\s*?([""'])?(\S.*?)(?:>|class|\1)";
  12.         while (input.Substring(input.Length - 3) != "END")
  13.         {
  14.             input += Console.ReadLine();
  15.         }
  16.         input = input.Remove(input.Length - 3);
  17.         Regex regex = new Regex(pattern);
  18.         MatchCollection matches = regex.Matches(input);
  19.         string fix;
  20.         foreach (Match item in matches)
  21.         {
  22.             fix = item.Groups[2].ToString();
  23.             fix = Regex.Replace(fix, @"\s{2,}", " ");
  24.             Console.WriteLine(fix);
  25.         }
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement