Answers for "how to validate an email"

1

validate email

function validateEmail(email) {
    const re = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
    return re.test(String(email).toLowerCase());
}
Posted by: Guest on January-06-2021
0

validate email address

public bool IsValid(string emailaddress)
{
    private const string EmailRegEx = @"^[\w!#$%&'*+\-/=?\^_`{|}~]+(\.[\w!#$%&'*+\-/=?\^_`{|}~]+)*"
         + "@"
         + @"((([\w]+([-\w]*[\w]+)*\.)+[a-zA-Z]+)|"
         + @"((([01]?[0-9]{1,2}|2[0-4][0-9]|25[0-5]).){3}[01]?[0-9]{1,2}|2[0-4][0-9]|25[0-5]))\z";
    return new Regex(EmailRegEx, RegexOptions.None).Match(emailaddress).Success;
}
Posted by: Guest on June-09-2021
0

validate email

# Language: Perl

sub Validate_Email($)
{
   my $sEmail = $_[0];
   my $sRetMsg = "";

   my $sUserNmRegex = "^[[:alnum:]]+([.!#\$\%&'*+-\/=?^_'{|]?[[:alnum:]]+)*";
   my $sDomainRegex = "@[[:alnum:]]+([.-]{1}[[:alnum:]]+)*";
   my $sEndRegex = "([.]{1}[[:alnum:]]+)+";

   #  Work
   #--------#

   if ($sEmail =~ /$sUserNmRegex$sDomainRegex$sEndRegex$/) {
      $sRetMsg = "Email is valid";
   }
   else {
      $sRetMsg = "Email is not valid";
   }

   return $sRetMsg;
}

my $sEmail = '[email protected]';
print "[Email:$sEmail] : " . Validate_Email($sEmail) . "\n";

# OUTPUT -> [Email:[email protected]] : Email is valid
Posted by: Guest on April-17-2020

Code answers related to "how to validate an email"

Code answers related to "Javascript"

Browse Popular Code Answers by Language