Advertisement
sivancheva

MatchFullName

Nov 3rd, 2017
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. using System;
  2. using System.Text.RegularExpressions;
  3. using System.Collections.Generic;
  4.  
  5.  
  6. namespace MatchFullName
  7. {
  8. class Program
  9. {
  10. public static void Main(string[] args)
  11. {
  12.  
  13. string pattern = @"\b[A-Z][a-z]+ [A-Z][a-z]+\b";
  14. string names = Console.ReadLine();
  15.  
  16. MatchCollection matchedNames = Regex.Matches(names, pattern);
  17.  
  18.  
  19. foreach (Match name in matchedNames)
  20. {
  21. Console.Write(name.Value + " ");
  22. }
  23.  
  24. Console.WriteLine();
  25.  
  26. }
  27. }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement