Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Text;
- using System.Text.RegularExpressions;
- namespace _06_EmailValidation
- {
- class Program
- {
- static void Main(string[] args)
- {
- int cycles = int.Parse(Console.ReadLine());
- string pattern = @"^([\$\%])(?<tag>[A-Z][a-z]{2,})\1: \[(?<first>\d+)\]\|\[(?<second>\d+)\]\|\[(?<third>\d+)\]\|$";
- for (int i = 0; i < cycles; i++)
- {
- string text = Console.ReadLine();
- Match match = Regex.Match(text, pattern);
- if (!match.Success)
- {
- Console.WriteLine("Valid message not found!");
- }
- else
- {
- int first = int.Parse(match.Groups["first"].Value);
- int second = int.Parse(match.Groups["second"].Value);
- int third = int.Parse(match.Groups["third"].Value);
- string tag = match.Groups["tag"].Value;
- Console.WriteLine($"{tag}: {(char)first}{(char)second}{(char)third}");
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement