Re: Email Verification Regular Expression - Mailing list pgsql-general

From Greg Sabino Mullane
Subject Re: Email Verification Regular Expression
Date
Msg-id 838ac1c6c22c31d17d8d6bf1a7e0a2f7@biglumber.com
Whole thread Raw
In response to Email Verfication Regular Expression  (Brad Nicholson <bnichols@ca.afilias.info>)
List pgsql-general
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


> Does anybody have regular expression handy to verfiy email addresses?

CREATE OR REPLACE FUNCTION goodemail(text) RETURNS BOOL LANGUAGE plperl AS
$$
my $lwsp = "(?:(?:\\r\\n)?[ \\t])";
my $specials = '()<>@,;:\\\\".\\[\\]';
my $controls = '\\000-\\037\\177';
my $dtext = "[^\\[\\]\\r\\\\]";
my $domain_literal = "\\[(?:$dtext|\\\\.)*\\]$lwsp*";
my $quoted_string = "\"(?:[^\\\"\\r\\\\]|\\\\.|$lwsp)*\"$lwsp*";
my $atom = "[^$specials $controls]+(?:$lwsp+|\\Z|(?=[\\[\"$specials]))";
my $word = "(?:$atom|$quoted_string)";
my $localpart = "$word(?:\\.$lwsp*$word)*";
my $sub_domain = "(?:$atom|$domain_literal)";
my $domain = "$sub_domain(?:\\.$lwsp*$sub_domain)*";
my $addr_spec = "$localpart\@$lwsp*$domain";
my $phrase = "$word*";
my $route = "(?:\@$domain(?:,\@$lwsp*$domain)*:$lwsp*)";
my $route_addr = "\\<$lwsp*$route?$addr_spec\\>$lwsp*";
my $mailbox = "(?:$addr_spec|$phrase$route_addr)";
my $group = "$phrase:$lwsp*(?:$mailbox(?:,\\s*$mailbox)*)?;\\s*";
my $address = "(?:$mailbox|$group)";
my $EMAILRE = qr{$lwsp*$address};

return $_[0] =~ $EMAILRE ? 1 : 0;

$$;



- --
Greg Sabino Mullane greg@turnstep.com
PGP Key: 0x14964AC8 200509071223
https://www.biglumber.com/x/web?pk=2529DF6AB8F79407E94445B4BC9B906714964AC8
-----BEGIN PGP SIGNATURE-----

iEYEARECAAYFAkMfFCgACgkQvJuQZxSWSshBlQCfTIJVNH2SH/g3PaVW4COA9x4q
evUAnRqTbkLI88kr5diqaqBb5jAacXcm
=6OXG
-----END PGP SIGNATURE-----



pgsql-general by date:

Previous
From: Lincoln Yeoh
Date:
Subject: Re: SLOOOOOOOW
Next
From: Ben
Date:
Subject: Re: Email Verfication Regular Expression