Advertisement
shady_obeyd

01. Match Full Name

Nov 2nd, 2017
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.64 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Text.RegularExpressions;
  7.  
  8.  
  9.  
  10.  
  11. namespace RegexFullName
  12. {
  13.     class Program
  14.     {
  15.         static void Main()
  16.         {
  17.             Regex pattern = new Regex(@"\b[A-Z][a-z]+\b \b[A-Z][a-z]+\b"); // Corrected pattern
  18.  
  19.             string name = Console.ReadLine();
  20.  
  21.             MatchCollection matches = pattern.Matches(name);
  22.  
  23.             foreach (Match m in matches)
  24.             {
  25.                 Console.Write(m.Groups[0] + " ");
  26.             }
  27.             Console.WriteLine();
  28.         }
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement