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;
- namespace _01.ExtractEmails
- {
- public class StartUp
- {
- public static void Main()
- {
- string emails = Console.ReadLine();
- string pattern = @"([\w.-]+\@[A-Za-z-]+)(\.[a-zA-Z]+)+";
- Regex regex = new Regex(pattern);
- MatchCollection matches = regex.Matches(emails);
- foreach (Match match in matches)
- {
- string result = match.ToString();
- if (!(result.StartsWith("-")||result.StartsWith("_")||result.StartsWith(".")
- || result.EndsWith("-")||result.EndsWith("_")||result.EndsWith(".")))
- {
- Console.WriteLine(result);
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment