Advertisement
Guest User

Untitled

a guest
Dec 7th, 2019
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. using System;
  2. using System.Text.RegularExpressions;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5.  
  6.  
  7. namespace ConsoleApp18
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. int n = int.Parse(Console.ReadLine());
  14. int countRegistrations = 0;
  15. for (int i = 0; i < n; i++)
  16. {
  17. string text = Console.ReadLine();
  18. string pattern = @"(U\$)([A-Z]{1}[a-z]{2,})\1(P@\$)([A-z]{5,}.*\d+)\3";
  19. Regex regex = new Regex(pattern);
  20. if (regex.IsMatch(text))
  21. {
  22. Console.WriteLine("Registration was successful");
  23. Match match = regex.Match(text);
  24. Console.WriteLine($"Username: {match.Groups[2]}, Password: {match.Groups[4]}");
  25. countRegistrations++;
  26. }
  27. else
  28. {
  29. Console.WriteLine("Invalid username or password");
  30. }
  31. }
  32. Console.WriteLine($"Successful registrations: {countRegistrations}");
  33. }
  34. }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement