Advertisement
Guest User

shit

a guest
May 27th, 2015
461
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. using System.IO;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Text;
  5. using System.Text.RegularExpressions;
  6.  
  7. class Program
  8. {
  9. private static List<String> _result;
  10.  
  11. static void Main()
  12. {
  13. _result = new List<String>();
  14. String input = GetInput();
  15.  
  16. GetResults(input);
  17. PrintResults();
  18. }
  19.  
  20. private static void PrintResults()
  21. {
  22. foreach (var i in _result)
  23. {
  24. Console.WriteLine(i);
  25. }
  26. }
  27.  
  28. private static void GetResults(String input)
  29. {
  30. //String pat = @"\u\s;
  31. String pattern = @"(?:<a)(?:[\s\n_0-9a-zA-Z=""()]*?.*?)(?:href([\s\n]*)?=(?:['""\s\n]*)?)([a-zA-Z:#\/._\-0-9!?=^+]*(\([""'a-zA-Z\s.()0-9]*\))?)(?:[\s\na-zA-Z=""()0-9]*.*?)?(?:\>)";
  32. Regex rex = new Regex(pattern);
  33. Match match = rex.Match(input);
  34.  
  35. while(match.Success)
  36. {
  37. if (!(match.Groups[2].Value == "fake"))
  38. {
  39. _result.Add(match.Groups[2].Value);
  40. }
  41. match = match.NextMatch();
  42. }
  43. }
  44.  
  45. private static String GetInput()
  46. {
  47. StringBuilder bld = new StringBuilder();
  48. while (true)
  49. {
  50. String input = Console.ReadLine();
  51. if (input == "END")
  52. {
  53. break;
  54. }
  55.  
  56. bld.Append(input);
  57. bld.Append("\n");
  58. }
  59.  
  60. return bld.ToString();
  61. }
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement