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