Advertisement
Spocoman

01. Match Full Name

Apr 18th, 2023 (edited)
897
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.82 KB | None | 0 0
  1. using System;
  2. using System.Text.RegularExpressions;
  3.  
  4. namespace MatchFullName
  5. {
  6.     internal class Program
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.             string names = Console.ReadLine();
  11.  
  12.             Regex pattern = new Regex(@"\b[A-Z][a-z]+ [A-Z][a-z]+ \b");
  13.  
  14.             MatchCollection matchedNames = pattern.Matches(names);
  15.  
  16.             foreach (Match name in matchedNames)
  17.             {
  18.                 Console.Write(name + " ");
  19.             }
  20.         }
  21.     }
  22. }
  23.  
  24. TARIKAT SOLUTION :)
  25.  
  26. using System;
  27. using System.Text.RegularExpressions;
  28.  
  29. namespace MatchFullName
  30. {
  31.     internal class Program
  32.     {
  33.         static void Main(string[] args)
  34.         {
  35.             Console.Write(string.Join(" ", Regex.Matches(Console.ReadLine(), @"\b[A-Z][a-z]+ [A-Z][a-z]+\b")));
  36.         }
  37.     }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement