MiroslavKisov

Trainegram

Nov 25th, 2017
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.70 KB | None | 0 0
  1. using System;
  2. using System.Text.RegularExpressions;
  3.  
  4. namespace _01.Trainegram
  5. {
  6.     public class StartUp
  7.     {
  8.         public static void Main()
  9.         {
  10.             string pattern = @"^(<\[[^A-Za-z0-9\n]*]\.)(\.\[[A-Za-z0-9]*]\.)*$";
  11.             Regex regex = new Regex(pattern);
  12.             while (true)
  13.             {
  14.                 string train = Console.ReadLine();
  15.                 if (train == "Traincode!")
  16.                 {
  17.                     break;
  18.                 }
  19.                 Match match = regex.Match(train);
  20.                 if (match.Success)
  21.                 {
  22.                     Console.WriteLine(match.ToString());
  23.                 }
  24.             }
  25.         }
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment