Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Text.RegularExpressions;
- using System.Threading.Tasks;
- /*
- * +359 2 222 2222,359-2-222-2222, +359/2/222/2222, +359-2 222 2222 +359 2-222-2222, +359-2-222-222, +359-2-222-22222 +359-2-222-2222
- */
- namespace _2.Match_Phone_Number
- {
- internal class Program
- {
- static void Main(string[] args)
- {
- //string pattern = @"\+([\d]{3} [2]? [0-9]{3} [0-9]{4})|(\+[\d]{3}-[2]?-[0-9]{3}-\d{4}\b)";
- string pattern = @"(\+359)(\-| )2(\2)\d{3}(\2)\d{4}\b";
- string input = Console.ReadLine();
- var matches = Regex.Matches(input, pattern);
- var phonse = matches
- .Cast<Match>()
- .Select(a => a.Value.Trim())
- .ToArray();
- Console.WriteLine(string.Join(", ", phonse));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement