Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Text.RegularExpressions;
- namespace MatchPhoneNumber
- {
- class Program
- {
- static void Main(string[] args)
- {
- string pattern = @"\+359(?<delimiter>[- ])\d{1}(\1)\d{3}(\1)\d{4}$";
- string input = Console.ReadLine();
- var matches = Regex.Matches(input, pattern);
- var matchedPhones = matches
- .Cast<Match>()
- .Select(a => a.Value.Trim())
- .ToArray();
- Console.WriteLine(string.Join(", ", matchedPhones));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement