Advertisement
Guest User

Untitled

a guest
Mar 25th, 2020
523
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text.RegularExpressions;
  5.  
  6.  
  7. namespace Registration
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. string pattern = @"(U\$)([A-z][a-z]{2,})(\1)P\@\$([a-z]{5,}([A-Z]+)?[0-9]+)P\@\$";
  14. Regex regex = new Regex(pattern);
  15. int count = 0;
  16. int n = int.Parse(Console.ReadLine());
  17. for (int i = 0; i < n; i++)
  18. {
  19. string input = Console.ReadLine();
  20. bool matchRequirement = regex.IsMatch(input);
  21. if (matchRequirement)
  22. {
  23.  
  24. Match data = regex.Match(input);
  25.  
  26.  
  27.  
  28. string group = data.Groups[4].Value;
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35. Console.WriteLine("Registration was successful");
  36.  
  37. Group username = data.Groups[2];
  38.  
  39. Console.WriteLine($"Username: {username}, Password: {group}");
  40.  
  41.  
  42. count++;
  43.  
  44. }
  45. else
  46. {
  47. Console.WriteLine("Invalid username or password");
  48. }
  49. }
  50.  
  51. Console.WriteLine($"Successful registrations: {count}");
  52. }
  53. }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement