Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Disclaimer: The creator of 'C# Shell (C# Offline Compiler)' is in no way responsible for the code posted by any user.
- using System;
- using System.IO;
- using System.Linq;
- using System.Collections.Generic;
- using System.Text.RegularExpressions;
- namespace CSharp_Shell
- {
- public static class Program
- {
- public static void Main()
- {
- string input = "In the Sofia Zoo there are 311 animals in total! ::Smiley:: This includes 3 **Tigers**, 1 ::Elephant:, 12 **Monk3ys**, a **Gorilla::, 5 ::fox:es: and 21 different types of :Snak::Es::. ::Mooning:: **Shy**";
- //string input = "5, 4, 3, 2, 1, go! The 1-th consecutive banana-eating contest has begun! ::Joy:: **Banana** ::Wink:: **Vali** ::valid_emoji::";
- //string input = "It is a long established fact that 1 a reader will be distracted by 9 the readable content of a page when looking at its layout. The point of using ::LoremIpsum:: is that it has a more-or-less normal 3 distribution of 8 letters, as opposed to using 'Content here, content 99 here', making it look like readable **English**.";
- string digits = @"\d";
- string pattern = @"([:]{2})([A-Z]{1}[a-z]{2,})([:]{2})|([*]{2})([A-Z]{1}[a-z]{2,})([*]{2})";
- var multiplayDigits = 1;
- var sumAlphabet = 0;
- Regex rg = new Regex(pattern);
- Regex dg = new Regex (digits);
- MatchCollection matchedDigits = dg.Matches(input);
- MatchCollection matchedInput = rg.Matches(input);
- var result = new List<string>();
- var sum = new List<int>();
- for (int count = 0; count < matchedDigits.Count; count++)
- {
- multiplayDigits *= int.Parse(matchedDigits[count].Value);
- }
- for (int count = 0; count < matchedInput.Count; count++)
- {
- for(int j= 2;j < matchedInput[count].Value.Length-2;j++)
- {
- sumAlphabet+=matchedInput[count].Value[j];
- }
- if(sumAlphabet > multiplayDigits)
- {
- result.Add(matchedInput[count].Value);
- }
- sumAlphabet = 0;
- }
- Console.WriteLine(multiplayDigits + " = *=digit");
- foreach(var i in result)
- {
- Console.WriteLine(i);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement