Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Text;
- using System.Text.RegularExpressions;
- namespace _2._1_Registration
- {
- class Program
- {
- static void Main(string[] args)
- {
- int number = int.Parse(Console.ReadLine());
- string passwordPattern = @"(U\$)([A-Za-z]{2,})\1(P\@\$)([A-Za-z]{5,}\d+)(P\@\$)";
- int count = 0;
- for (int i = 0; i < number; i++)
- {
- string input = Console.ReadLine();
- Match passwordMatch = Regex.Match(input, passwordPattern);
- if (passwordMatch.Success)
- {
- Console.WriteLine("Registration was successful");
- string username = passwordMatch.Groups[2].Value;
- string password = passwordMatch.Groups[4].Value;
- Console.WriteLine($"Username: {username}, Password: {password}");
- count++;
- }
- else
- {
- Console.WriteLine("Invalid username or password");
- }
- }
- Console.WriteLine($"Successful registrations: {count}");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement