Regex for matching e-mail in C#. Came across http://emailregex.com/ which has a horrible example, so ended up making my own loosely based on that.
It leaves much to be desired, but will cover most use cases well enough.
1 2 3 4 |
public static readonly Regex _emailRegex = new Regex( @"^[\w0-9!#$%&'*+/=?^_`{|}~-]{1,50}(?:\.[\w0-9!#$%&'*+/=?^_`{|}~-]{1,50}){0,8}" + @"@(?:[-\w0-9]{1,50}?\.){1,10}[-\w0-9]{2,50}?$", RegexOptions.Compiled); |