Advertisement
Aborigenius

Match Full Name

Aug 24th, 2017
120
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;
  5. using System.Text.RegularExpressions;
  6. using System.Threading.Tasks;
  7.  
  8. namespace RegEx
  9. {
  10.     class Program
  11.     {
  12.         static void Main(string[] args)
  13.         {
  14.             string pattern = @"(\b[A-Z][a-z]+ [A-Z][a-z]+\b)";
  15.  
  16.             string names = Console.ReadLine();
  17.  
  18.             MatchCollection matchedNames = Regex.Matches(names, pattern);
  19.  
  20.             foreach (Match name in matchedNames)
  21.             {
  22.                 Console.Write(name.Value + " ");
  23.             }
  24.         }
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement