Advertisement
Guest User

ExtraxEmailsRegexExercises

a guest
Feb 20th, 2017
515
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. namespace _01.ExtractEmails
  2. {
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Text.RegularExpressions;
  7.  
  8. public class ExtractEmails
  9. {
  10. public static void Main()
  11. {
  12. var input = Console.ReadLine();
  13. var pattern = @"[A-Za-z0-9](\.|-|_|[A-Za-z0-9])+[A-Za-z0-9]@[A-Za-z]+(\.|-)?[A-Za-z]+\.?\w+";
  14. Regex regex = new Regex(pattern);
  15. var matches = Regex.Matches(input, pattern);
  16. foreach (Match match in matches)
  17. {
  18. Console.WriteLine(match);
  19. }
  20. }
  21. }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement