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