Advertisement
desislava_topuzakova

Untitled

Sep 19th, 2022
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. using System;
  2. using System.Text.RegularExpressions;
  3.  
  4. namespace _02._Employees
  5. {
  6. class Program
  7. {
  8. static void Main(string[] args)
  9. {
  10. int n = int.Parse(Console.ReadLine());
  11. 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]*)";
  12.  
  13. for (int i = 0; i < n; i++)
  14. {
  15. string input = Console.ReadLine();
  16. Regex regexPattern = new Regex(pattern);
  17. Match employeeInfo = Regex.Match(input, pattern);
  18.  
  19. if (employeeInfo.Success)
  20. {
  21. string employeeName = employeeInfo.Groups["employeeName"].Value;
  22. string jobPosition = employeeInfo.Groups["jobPosition"].Value;
  23. jobPosition = jobPosition.Replace("&", " ");
  24. string companyName = employeeInfo.Groups["companyName"].Value;
  25. Console.WriteLine($"{employeeName} is {jobPosition} at {companyName}");
  26. }
  27. }
  28. }
  29. }
  30. }
  31.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement