Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Text.RegularExpressions;
- namespace P02
- {
- class Program
- {
- static void Main(string[] args)
- {
- var pattern =
- @"([\W]+|[\w]+)>(?<digits>[0-9]{3})\|(?<lower>[a-z]{3})\|(?<upper>[A-Z]{3})\|(?<symbols>.[^<>]*)<\1";
- // problem with "<> at symbols group"
- var regex = new Regex(pattern);
- int n = int.Parse(Console.ReadLine());
- for (int i = 0; i < n; i++)
- {
- string input = Console.ReadLine();
- if (regex.IsMatch(input))
- {
- var match = regex.Match(input);
- string password = regex.Match(input).Groups["digits"].ToString();
- password += regex.Match(input).Groups["lower"].ToString();
- password += regex.Match(input).Groups["upper"].ToString();
- password += regex.Match(input).Groups["symbols"].ToString();
- Console.WriteLine($"Password: {password}");
- }
- else
- {
- Console.WriteLine($"Try another password!");
- }
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment