I have the following regex for the email validation:
private const string ValidEmailRegexPattern = @"^(?:[^@\s\\(),:;<>[\]""]+|(?:(?:^|\.)""(?:[^\r\\"";]|(?:\\[\\""]))*"")+)+(?<=^.{1,64})@[^\s~!@#$%^&*()=+_{}\|;,`'""?<>]{1,256}$";
public static bool IsValidEmail(string email)
{
return !string.IsNullOrWhiteSpace(email) && ValidEmailRegex.IsMatch(email);
}
But it is froze when input is valid email, but with maximum valid length (254 symbols) like this:
"123...@gmail.com"
- 254
symbols, including 244
numbers and @gmail.com
.
How to change my regex? I want that my program can handle that type of email address.