Advertisement
fr3s7ed

Untitled

Jun 18th, 2018
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Text.RegularExpressions;
  4.  
  5. namespace MatchPhoneNumber
  6. {
  7. class Program
  8. {
  9. static void Main(string[] args)
  10. {
  11. string pattern = @"\+359(?<delimiter>[- ])\d{1}(\1)\d{3}(\1)\d{4}$";
  12.  
  13. string input = Console.ReadLine();
  14. var matches = Regex.Matches(input, pattern);
  15.  
  16. var matchedPhones = matches
  17. .Cast<Match>()
  18. .Select(a => a.Value.Trim())
  19. .ToArray();
  20.  
  21.  
  22. Console.WriteLine(string.Join(", ", matchedPhones));
  23.  
  24. }
  25. }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement