Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Text.RegularExpressions;
- namespace _02._Match_Phone_Number
- {
- class Program
- {
- static void Main(string[] args)
- {
- string pattern = @"\+([359]+)([- ])2(\2)(\d{3})(\2)(\d{4})\b";
- string phonesInputs = Console.ReadLine();
- Regex phonePatternex = new Regex(pattern);
- var match = phonePatternex.Matches(phonesInputs);
- int phoneNumbersCount = 0;
- foreach (var phoneNumber in match)
- {
- string collection = phoneNumber + ", ";
- phoneNumbersCount += 1;
- if (phoneNumbersCount == match.Count)
- {
- Console.Write(collection.Remove(collection.Length - 2));
- }
- else
- {
- Console.Write(collection);
- }
- }
- Console.WriteLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement