Is Valid Email - C#

Is Valid Email - C#

code snippet

c#
public bool IsValidEmail(string strIn)
{
    bool invalid = false;
    if (String.IsNullOrEmpty(strIn))
        return false;
    if (invalid)
        return false;
    // Return true if strIn is in valid e-mail format.
    try
    {
        return Regex.IsMatch(strIn,
              @"^(?("")("".+?(?<!\\)""@)|(([0-9a-z]((\.(?!\.))|[-!#\$%&'\*\+/=\?\^`\{\}\|~\w])*)(?<=[0-9a-z])@))" +
              @"(?(\[)(\[(\d{1,3}\.){3}\d{1,3}\])|(([0-9a-z][-\w]*[0-9a-z]*\.)+[a-z0-9][\-a-z0-9]{0,22}[a-z0-9]))$",
              RegexOptions.IgnoreCase, TimeSpan.FromMilliseconds(250));
    }
    catch (RegexMatchTimeoutException)
    {
        return false;
    }
}

"One today is worth two tomorrows"

Contact me!

Have questions? Feel free to use the form or send me an email with any questions.

I will be responsive to your requests and your questions.