Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Text.RegularExpressions;
- using System.Collections.Generic;
- using System.Linq;
- namespace ConsoleApp18
- {
- class Program
- {
- static void Main(string[] args)
- {
- int n = int.Parse(Console.ReadLine());
- int countRegistrations = 0;
- for (int i = 0; i < n; i++)
- {
- string text = Console.ReadLine();
- string pattern = @"(U\$)([A-Z]{1}[a-z]{2,})\1(P@\$)([A-z]{5,}.*\d+)\3";
- Regex regex = new Regex(pattern);
- if (regex.IsMatch(text))
- {
- Console.WriteLine("Registration was successful");
- Match match = regex.Match(text);
- Console.WriteLine($"Username: {match.Groups[2]}, Password: {match.Groups[4]}");
- countRegistrations++;
- }
- else
- {
- Console.WriteLine("Invalid username or password");
- }
- }
- Console.WriteLine($"Successful registrations: {countRegistrations}");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement