SHARE
TWEET

Untitled

a guest Mar 21st, 2019 109 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.            
  14.             Regex namePattern = new Regex(@"@(?<name>[\S\s]*?)\|");
  15.             Regex agePattern = new Regex(@"#(?<age>[\S\s]*?)\*");
  16.  
  17.             for (int i = 0; i < n; i++)
  18.             {
  19.                 string input = Console.ReadLine();
  20.  
  21.                 if (namePattern.IsMatch(input) && agePattern.IsMatch(input))
  22.                 {
  23.                   Console.WriteLine($"{namePattern.Match(input).Groups["name"].ToString()} is {agePattern.Match(input).Groups["age"].ToString()} years old.");
  24.                 }
  25.             }
  26.  
  27.         }
  28.     }
  29. }
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