Advertisement
Guest User

Password

a guest
Dec 5th, 2019
335
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.96 KB | None | 0 0
  1. using System;
  2. using System.Text.RegularExpressions;
  3.  
  4. namespace Test_2_03._08._2019_Group_2
  5. {
  6.     class Program
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.             string pattern = @"^(\D+)>(\d{3})\|([a-z]{3})\|([A-Z]{3})\|([^\<\>]{3})<\1$";
  11.  
  12.             int lines = int.Parse(Console.ReadLine());
  13.  
  14.             for (int i = 0; i < lines; i++)
  15.             {
  16.                 string input = Console.ReadLine();
  17.  
  18.                 Match matches = Regex.Match(input, pattern);
  19.  
  20.                 if (matches.Success)
  21.                 {
  22.                     string password = matches.Groups[2].Value + matches.Groups[3].Value
  23.                         + matches.Groups[4].Value + matches.Groups[5].Value;
  24.  
  25.                     Console.WriteLine("Password: "+ password);
  26.                 }
  27.                 else
  28.                 {
  29.                     Console.WriteLine("Try another password!");
  30.                 }
  31.             }
  32.  
  33.         }
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement