SHARE
TWEET

Untitled

a guest Mar 21st, 2019 75 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top