Militsa

05. Match Full Name

Nov 29th, 2017
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.59 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text.RegularExpressions;
  5. using System.Threading.Tasks;
  6.  
  7. namespace _05.Match_Full_Name
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             String text = Console.ReadLine();
  14.             String pattern = @"\b([A-Z]{1}[a-z]+) ([A-Z]{1}[a-z]+)\b";
  15.  
  16.             MatchCollection matches = Regex.Matches(text, pattern);
  17.  
  18.             foreach (Match i in matches)
  19.             {
  20.                 Console.Write(String.Join(" ", i.Groups[0]) + " ");
  21.             }
  22.         }
  23.     }
  24. }
Add Comment
Please, Sign In to add comment