Advertisement
abushik

Password

Apr 3rd, 2020
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. using System;
  2. using System.Text.RegularExpressions;
  3.  
  4. namespace Password
  5. {
  6. class Program
  7. {
  8. static void Main(string[] args)
  9. {
  10. Regex regex = new Regex(@"^(.+)>([0-9]{3})\|([a-z]{3})\|([A-Z]{3})\|([^<>]{3})<(\1)$");
  11.  
  12. int n = int.Parse(Console.ReadLine());
  13.  
  14. for (int i = 0; i < n; i++)
  15. {
  16. string password = Console.ReadLine();
  17. Match match = regex.Match(password);
  18.  
  19. if (match.Success)
  20. {
  21. Console.WriteLine($"Password: {match.Groups[2]}{match.Groups[3]}{match.Groups[4]}{match.Groups[5]}");
  22. }
  23. else
  24. {
  25. Console.WriteLine("Try another password!");
  26. }
  27. }
  28. }
  29. }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement