Validate Email Address

Check if a string is properly formed and so COULD BE a valid email address see https://regexr.com/4te27

           
        public static bool IsValidEmailAddress(this string s)
        {
            Regex regex = new Regex(@"^[\w-\.][email protected]([\w-]+\.)+[\w-]{2,4}$");
            return regex.IsMatch(s);
        }
 
    

Returns true/false - call like this...

         
         str.IsValidEmailAddress();