Deserboy

Password Retake Exam Fundamentals

Aug 9th, 2019
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.26 KB | None | 0 0
  1. using System;
  2. using System.Text;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text.RegularExpressions;
  6.  
  7. namespace Playing
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int n = int.Parse(Console.ReadLine());
  14.             for (int i = 1; i <= n; i++)
  15.             {
  16.                 string password = Console.ReadLine();
  17.                 Regex regex = new Regex(@"(\S+)>(\d{3})\|([a-z]{3})\|([A-Z]{3})\|([^<>]{3})<\1");
  18.                 bool match = regex.IsMatch(password);
  19.                 if (match == false)
  20.                 {
  21.                     Console.WriteLine("Try another password!");
  22.                     continue;
  23.                 }
  24.                 else
  25.                 {
  26.                     Match matching = regex.Match(password);
  27.                     string numbers = matching.Groups[2].Value;
  28.                     string lowerLetters = matching.Groups[3].Value;
  29.                     string upperLetters = matching.Groups[4].Value;
  30.                     string symbols = matching.Groups[5].Value;
  31.                     string output = numbers + lowerLetters + upperLetters + symbols;
  32.                     Console.WriteLine($"Password: {output}");
  33.  
  34.                 }
  35.             }
  36.         }
  37.     }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment