Regular expression to match an email address : Email « Regular Expressions « C# / C Sharp






Regular expression to match an email address

 

//The MIT License (MIT)
//http://arolibraries.codeplex.com/license
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AroLibraries.ExtensionMethods.Strings
{
    public static class StringExt
    {
        public static bool Ext_IsValidEmailAddress(this string s)
        {
            Regex regex = new Regex(@"^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$");
            return regex.IsMatch(s);
        }
    }
}

   
  








Related examples in the same category

1.Compare two DateTime values
2.Use regular expression to check email format
3.Is email by regular expression