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