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