// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; using System.Text.RegularExpressions; namespace E { public class Program { private static readonly Regex re = new Regex(@"([^@<>]+@[a-z0-9\-.]+)", RegexOptions.Compiled); public static string FindEmail(string addr) { return re.Match(addr).Value; } public static void Main(string[] args) { Console.WriteLine(FindEmail("email@domain.com")); Console.WriteLine(FindEmail("Name ")); Console.WriteLine(FindEmail("Name")); } } }