1const emailRegex = RegExp(
2 /^[a-zA-Z0-9.!#$%&’*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/
3 );
1function validateEmail(email) {
2 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,}))$/;
3 return re.test(String(email).toLowerCase());
4}
5
1
2# Language: Perl
3
4sub Validate_Email($)
5{
6 my $sEmail = $_[0];
7 my $sRetMsg = "";
8
9 my $sUserNmRegex = "^[[:alnum:]]+([.!#\$\%&'*+-\/=?^_'{|]?[[:alnum:]]+)*";
10 my $sDomainRegex = "@[[:alnum:]]+([.-]{1}[[:alnum:]]+)*";
11 my $sEndRegex = "([.]{1}[[:alnum:]]+)+";
12
13 # Work
14 #--------#
15
16 if ($sEmail =~ /$sUserNmRegex$sDomainRegex$sEndRegex$/) {
17 $sRetMsg = "Email is valid";
18 }
19 else {
20 $sRetMsg = "Email is not valid";
21 }
22
23 return $sRetMsg;
24}
25
26my $sEmail = 'EmailExample@gmail.com';
27print "[Email:$sEmail] : " . Validate_Email($sEmail) . "\n";
28
29# OUTPUT -> [Email:EmailExample@gmail.com] : Email is valid
30
1UserSchema.path('email').validate(function (email) {
2 return email.length
3}, 'The e-mail field cannot be empty.')