Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace _01.ExtractPersonInformation
- {
- using System;
- using System.Collections.Generic;
- using System.Text.RegularExpressions;
- public class Program
- {
- public static void Main()
- {
- int n = int.Parse(Console.ReadLine());
- var people = new List<string>();
- Regex pattern = new Regex(@"@(?<name>[\S\s]*?)\|([\S\s]*?)#(?<age>[\S\s]*?)\*");
- for (int i = 0; i < n; i++)
- {
- string input = Console.ReadLine();
- if (pattern.IsMatch(input))
- {
- people.Add($"{pattern.Match(input).Groups["name"].ToString()} is {pattern.Match(input).Groups["age"].ToString()} years old.");
- }
- }
- Console.WriteLine(string.Join(Environment.NewLine,people));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement