Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Text.RegularExpressions;
- using System.Linq;
- namespace Lekciq_02.Match_Phone_Number
- {
- class Program
- {
- static void Main(string[] args)
- {
- string input = Console.ReadLine();
- Regex regex = new Regex(@"(?<start>^|[\s])(?<country>\+359)(?<separator>[\- ])(?<number>2)\k<separator>[0-9]{3}\k<separator>[0-8]{4}\b");
- MatchCollection matches = regex.Matches(input);
- var array = matches.Cast<Match>().Select(a => a.Value.Trim()).ToArray();
- Console.WriteLine(string.Join(", ", array));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement