Advertisement
IvanBorisovG

ToFix

Mar 3rd, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.47 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text.RegularExpressions;
  5. using System.Numerics;
  6. using System.Text;
  7.  
  8. namespace _03.Regexmon
  9. {
  10.     class Program
  11.     {
  12.         static void Main(string[] args)
  13.         {
  14.             string input = Console.ReadLine();
  15.  
  16.             var bojoRegex = new Regex(@"[A-Za-z]+-[A-Za-z]+");
  17.             var didiRegex = new Regex(@"[^-A-Za-z]+");
  18.  
  19.             var count = 0;
  20.            
  21.             while (input != string.Empty)
  22.             {
  23.                 if (count % 2 == 0)
  24.                 {
  25.                     if (didiRegex.IsMatch(input))
  26.                     {
  27.                         var match = didiRegex.Match(input);
  28.                         Console.WriteLine(match);
  29.                         input = didiRegex.Replace(input, string.Empty);
  30.                     }
  31.                     else
  32.                     {
  33.                         break;
  34.                     }
  35.                 }
  36.                 else
  37.                 {
  38.                     if (bojoRegex.IsMatch(input))
  39.                     {
  40.                         var match = bojoRegex.Match(input);
  41.                         Console.WriteLine(match);
  42.                         input = bojoRegex.Replace(input, string.Empty);
  43.  
  44.                     }
  45.                     else
  46.                     {
  47.                         break;
  48.                     }
  49.  
  50.                 }
  51.                 count++;
  52.             }
  53.         }
  54.     }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement