Advertisement
Guest User

Untitled

a guest
May 18th, 2015
273
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.53 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Text.RegularExpressions;
  6. using System.Threading.Tasks;
  7. using System.IO;
  8.  
  9. namespace P8_UseYourChains
  10. {
  11. class Program
  12. {
  13. static void Main(string[] args)
  14. {
  15. Console.SetIn(new StreamReader(Console.OpenStandardInput(8192)));
  16. string input = Console.ReadLine();
  17. string pattern = @"(?<=<p>)(.+?)(?=<\/p>)";
  18. StringBuilder wholeText = new StringBuilder();
  19. MatchCollection matches = Regex.Matches(input, pattern);
  20. foreach (Match match in matches)
  21. {
  22. wholeText.Append(match.ToString() + " ");
  23. }
  24. string replace = @"[^a-z0-9]";
  25. string replaced = wholeText.ToString();
  26. replaced=Regex.Replace(replaced, replace, " ");
  27. string removeSpaces = @"\s{2,}";
  28. replaced = Regex.Replace(replaced, removeSpaces, " ");
  29. char[] arr = replaced.ToCharArray();
  30. for (int i = 0; i < arr.Length; i++)
  31. {
  32. if(arr[i] >= 'a' && arr[i] <= 'm')
  33. {
  34. Console.Write((char)(arr[i] + 13));
  35. }
  36. else if (arr[i] >= 'n' && arr[i] <= 'z')
  37. {
  38. Console.Write((char)(arr[i] - 13));
  39. }
  40. else
  41. {
  42. Console.Write(arr[i]);
  43. }
  44. }
  45. }
  46. }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement