RockyMountainHigh RockyMountainHigh - 1 year ago 94
C# Question

Email Regex that DOES include unicode domains

I was wondering if anybody has found a solution that validates an email that includes unicode characters as in from a unicode domain? I have searched at length and have yet to find a solution that works.

Tal Tal
Answer Source

I had the same issue and came up with an intelligent solution \p{L}. Please check it out:

private static bool IsEmailValid(string email) {
    System.Text.RegularExpressions.Regex re = new Regex(@"^[\p{L}0-9!$'*+\-_]+(\.[\p{L}0-9!$'*+\-_]+)*@[\p{L}0-9]+(\.[\p{L}0-9]+)*(\.[\p{L}]{2,})$", RegexOptions.CultureInvariant | RegexOptions.IgnoreCase);

    return re.IsMatch(email);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download