Advertisement
Guest User

Untitled

a guest
Mar 21st, 2019
263
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.87 KB | None | 0 0
  1. namespace _01.ExtractPersonInformation
  2. {
  3.     using System;
  4.     using System.Collections.Generic;
  5.     using System.Text.RegularExpressions;
  6.  
  7.     public class Program
  8.     {
  9.         public static void Main()
  10.         {
  11.             int n = int.Parse(Console.ReadLine());
  12.  
  13.             var people = new List<string>();
  14.            
  15.             Regex pattern = new Regex(@"@(?<name>[\S\s]*?)\|([\S\s]*?)#(?<age>[\S\s]*?)\*");
  16.  
  17.             for (int i = 0; i < n; i++)
  18.             {
  19.                 string input = Console.ReadLine();
  20.  
  21.                 if (pattern.IsMatch(input))
  22.                 {
  23.                     people.Add($"{pattern.Match(input).Groups["name"].ToString()} is {pattern.Match(input).Groups["age"].ToString()} years old.");
  24.                 }
  25.             }
  26.  
  27.             Console.WriteLine(string.Join(Environment.NewLine,people));
  28.         }
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement