Advertisement
YavorGrancharov

Trainegram(exam_task03)

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