Advertisement
Guest User

Untitled

a guest
Apr 6th, 2020
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.76 KB | None | 0 0
  1. using System;
  2. using System.Text.RegularExpressions;
  3.  
  4. namespace regex
  5. {
  6.     class Program
  7.     {
  8.        
  9.         static void Main(string[] args)
  10.         {
  11.             Regex R;
  12.             string s;
  13.             int counter = 0;
  14.             string pattern = @"(^[0-6](TBX|TAX)\s((\d\d\d[1-9])|(\d\d[1-9]\d)|(\d[1-9]\d\d)|([1-9]\d\d\d))$)|^7(TBX|TAX|TEX)\s((\d\d\d[1-9])|(\d\d[1-9]\d)|(\d[1-9]\d\d)|([1-9]\d\d\d))$";
  15.             int n = Int32.Parse(Console.ReadLine());
  16.  
  17.             for(int i = 0;i<n;i++)
  18.             {
  19.                 s = Console.ReadLine();
  20.                 Match M = Regex.Match(s, pattern);
  21.                 if (M != Match.Empty)
  22.                     counter++;
  23.             }
  24.             Console.WriteLine(counter);
  25.         }
  26.  
  27.     }
  28.  
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement