Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Text.RegularExpressions;
- namespace Use_Your_Chains_Buddy
- {
- class Program
- {
- static void Main()
- {
- string htmlText = Console.ReadLine();
- string pattern = @"<\s*p\s*>(.*?)<\s*\/p\s*>";
- string patternLetterAndDigit = "[^a-z0-9\n]{2,}";
- string patternParagraph = @"[^<p>\/]+";
- List<string> text = new List<string>();
- List<char> alphabet = new List<char>();
- StringBuilder sb = new StringBuilder();
- MatchCollection matches = Regex.Matches(htmlText, pattern);
- foreach (Match match in matches)
- {
- string currentMatchStr = match.ToString();
- Match currentMatch = Regex.Match(currentMatchStr, patternParagraph);
- string currentText = currentMatch.ToString();
- string result = Regex.Replace(currentText, patternLetterAndDigit, " ");
- text.Add(result);
- }
- for (char i = 'a'; i <= 'z'; i++)
- {
- alphabet.Add(i);
- }
- int convertIndex;
- string currentString = null;
- for (int i = 0; i < text.Count; i++)
- {
- currentString = text[i];
- for (int j = 0; j < currentString.Length; j++)
- {
- if (char.IsLetter(currentString[j]))
- {
- int indexLetter = alphabet.IndexOf(currentString[j]);
- if (indexLetter < 13)
- {
- convertIndex = indexLetter + 13;
- sb.Append(alphabet[convertIndex]);
- }
- else
- {
- convertIndex = indexLetter - 13;
- sb.Append(alphabet[convertIndex]);
- }
- }
- else
- {
- sb.Append(currentString[j]);
- }
- }
- }
- Console.WriteLine(sb);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement