Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Text.RegularExpressions;
- namespace _02._Employees
- {
- class Program
- {
- static void Main(string[] args)
- {
- int n = int.Parse(Console.ReadLine());
- string pattern = @"(?<employeeName>[A-Z][a-z]{3,}\s[A-Z][a-z]{3,})[\#]+(?<jobPosition>[A-Za-z]+\b\&?\b[A-Za-z]*[A-Za-z]*\b\&?\b[A-Za-z]*)\d{2}(?<companyName>[A-Za-z]+[\d]*\s[Ltd.]*[JSC]*)";
- for (int i = 0; i < n; i++)
- {
- string input = Console.ReadLine();
- Regex regexPattern = new Regex(pattern);
- Match employeeInfo = Regex.Match(input, pattern);
- if (employeeInfo.Success)
- {
- string employeeName = employeeInfo.Groups["employeeName"].Value;
- string jobPosition = employeeInfo.Groups["jobPosition"].Value;
- jobPosition = jobPosition.Replace("&", " ");
- string companyName = employeeInfo.Groups["companyName"].Value;
- Console.WriteLine($"{employeeName} is {jobPosition} at {companyName}");
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement