Advertisement
radidim

P02.Emoji Detector (C# Shell App Paste)

Jun 9th, 2020
1,106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.20 KB | None | 0 0
  1. //Disclaimer: The creator of 'C# Shell (C# Offline Compiler)' is in no way responsible for the code posted by any user.
  2. using System;
  3. using System.IO;
  4. using System.Linq;
  5. using System.Collections.Generic;
  6. using System.Text.RegularExpressions;
  7.  
  8. namespace CSharp_Shell
  9. {
  10.     public static class Program
  11.     {
  12.         public static void Main()
  13.        {
  14.         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**";
  15.         //string input = "5, 4, 3, 2, 1, go! The 1-th consecutive banana-eating contest has begun! ::Joy:: **Banana** ::Wink:: **Vali** ::valid_emoji::";
  16.         //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**.";
  17.         string digits = @"\d";
  18.         string pattern = @"([:]{2})([A-Z]{1}[a-z]{2,})([:]{2})|([*]{2})([A-Z]{1}[a-z]{2,})([*]{2})";
  19.         var multiplayDigits = 1;
  20.         var sumAlphabet = 0;
  21.         Regex rg = new Regex(pattern);
  22.         Regex dg = new Regex (digits);
  23.         MatchCollection matchedDigits = dg.Matches(input);
  24.         MatchCollection matchedInput = rg.Matches(input);
  25.         var result = new  List<string>();
  26.         var sum = new List<int>();
  27.         for (int count = 0; count < matchedDigits.Count; count++)
  28.         {
  29.             multiplayDigits *= int.Parse(matchedDigits[count].Value);
  30.         }
  31.         for (int count = 0; count < matchedInput.Count; count++)
  32.         {
  33.             for(int j= 2;j < matchedInput[count].Value.Length-2;j++)
  34.             {
  35.                
  36.                 sumAlphabet+=matchedInput[count].Value[j];
  37.             }
  38.              if(sumAlphabet > multiplayDigits)
  39.                 {
  40.                     result.Add(matchedInput[count].Value);
  41.                 }
  42.                 sumAlphabet = 0;
  43.         }
  44.        
  45.         Console.WriteLine(multiplayDigits + " = *=digit");
  46.         foreach(var i in result)
  47.         {
  48.             Console.WriteLine(i);
  49.         }
  50.        }
  51.     }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement