Created
February 17, 2021 03:00
-
-
Save maximgorbatyuk/806b7b4afc25f72076f6da933648df43 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Text.RegularExpressions; | |
namespace Utils.Helpers | |
{ | |
public class EmailValidRegex : Regex | |
{ | |
private const string Pattern = | |
@"^(?("")("".+?(?<!\\)""@)|(([0-9a-z]((\.(?!\.))|[-!#\$%&'\*\+/=\?\^`\{\}\|~\w])*)(?<=[0-9a-z])@))" + | |
@"(?(\[)(\[(\d{1,3}\.){3}\d{1,3}\])|(([0-9a-z][-0-9a-z]*[0-9a-z]*\.)+[a-z0-9][\-a-z0-9]{0,22}[a-z0-9]))$"; | |
public EmailValidRegex() | |
: base( | |
pattern: Pattern, | |
options: RegexOptions.Compiled | RegexOptions.IgnoreCase, | |
matchTimeout: TimeSpan.FromMilliseconds(250)) | |
{ | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment