Advertisement
IvanBorisovG

04. Fix Emails

Feb 25th, 2018
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.83 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text.RegularExpressions;
  5.  
  6. namespace FixEmails
  7. {
  8.     class Program
  9.     {
  10.         static void Main(string[] args)
  11.         {
  12.             var command = Console.ReadLine();
  13.             var email = "";
  14.  
  15.             while (command != "stop")
  16.             {            
  17.                 email = Console.ReadLine();
  18.  
  19.                 var pattern = new Regex(@"[A-Za-z]+\@[A-Za-z]+\.[^(uk)(us)\s]+");
  20.  
  21.                 var matches = pattern.Matches(email);
  22.  
  23.                 foreach (Match username in matches)
  24.                 {
  25.                     Console.WriteLine($"{command} -> {username.Value.Trim()}");
  26.                     break;
  27.                 }
  28.                 command = Console.ReadLine();
  29.             }                  
  30.         }
  31.     }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement