Guest User

Untitled

a guest
Feb 21st, 2016
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 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. class MathPhoneNumber
  9. {
  10. static void Main()
  11. {
  12. string phoneNumber = @"359-2-222-2222, +359/2/222/2222, +359-2 222 2222, +359 2-222-2222, +359-2-222-222, +359-2-222-22222,
  13. +359 2 222 2222, +359-2-222-2222";
  14. string pattern = @"^|[+359]+(-| )[2]\1[\d]{3}\1[\d]{4}\b";
  15.  
  16. MatchCollection matches = Regex.Matches(phoneNumber, pattern);
  17.  
  18. foreach (Match match in matches)
  19. {
  20. Console.WriteLine("{0} ", match);
  21. }
  22.  
  23. }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment