Advertisement
Guest User

Untitled

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