Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.IO;
- using System.Linq;
- using System.Text;
- using System.Text.RegularExpressions;
- class UseYourChainsBuddy
- {
- static void Main(string[] args)
- {
- int bufSize = 8192;
- Stream inStream = Console.OpenStandardInput(bufSize);
- Console.SetIn(new StreamReader(inStream, Console.InputEncoding, false, bufSize));
- string input = Console.ReadLine();
- string pattern = @"<p>(.*?)<\/p>"; //tried this too same result @"(?<=<p>)(.*?)<?=<\/p>)"
- string[] words = Regex.Matches(input, pattern)
- .Cast<Match>()
- .Select(m => m.Groups[1].Value) //m.Value with the old regex above
- .ToArray();
- for (int word = 0; word < words.Length; word++)
- {
- words[word] = Regex.Replace(words[word], @"[^a-z\d]+", " ");
- StringBuilder builder = new StringBuilder();
- for (int letter = 0; letter < words[word].Length; letter++)
- {
- if (words[word][letter] >= 'a' && words[word][letter] <= 'm')
- {
- builder.Append((char)(words[word][letter] + 13));
- }
- else if (words[word][letter] >= 'n' && words[word][letter] <= 'z')
- {
- builder.Append((char)(words[word][letter] - 13));
- }
- else
- {
- builder.Append(words[word][letter]);
- }
- }
- words[word] = builder.ToString();
- }
- string output = string.Join(" ", words);
- output = Regex.Replace(output, @"\s+|\n+", " ");
- Console.WriteLine(output);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment