Advertisement
martinvalchev

Extract_Emails

Feb 23rd, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.63 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Text.RegularExpressions;
  6. using System.Threading.Tasks;
  7.  
  8. namespace Extract_Emails
  9. {
  10.     class Program
  11.     {
  12.         static void Main(string[] args)
  13.         {
  14.             string input = Console.ReadLine();
  15.             string pattern = @"(^|(?<=\s))[A-Za-z0-9]+(\.|-|_)?[A-Za-z0-9]+@[A-Za-z]+-?[A-Za-z]*(\.[A-Za-z]+)+\b";
  16.  
  17.             MatchCollection match =  Regex.Matches(input, pattern);
  18.  
  19.             foreach (Match m in match)
  20.             {
  21.                 Console.WriteLine(m.Value);
  22.             }
  23.  
  24.         }
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement