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 _02.Problem02
- {
- class Program
- {
- static void Main(string[] args)
- {
- string regex = @"!([A-Z][a-z][a-z][a-z]+)!:\[([A-Za-z][A-Za-z][A-Za-z][A-Za-z][A-Za-z][A-Za-z][A-Za-z][A-Za-z]+)]";
- int n = int.Parse(Console.ReadLine());
- for (int i = 0; i < n; i++)
- {
- string input = Console.ReadLine();
- Match match = Regex.Match(input, regex);
- if (!match.Success)
- {
- Console.WriteLine("The message is invalid");
- continue;
- }
- else
- {
- string command = match.Groups[1].Value;
- string message = match.Groups[2].Value;
- Console.Write($"{command}: ");
- for (int j = 0; j < message.Length; j++)
- {
- Console.Write($"{(int)message[j]} ");
- }
- Console.WriteLine();
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment