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